From 9c3c6ca5a3310e178c9962bee246ff75e23d0bc2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ren=C3=A9=20Canna=C3=B2?= Date: Wed, 3 Jul 2024 20:08:30 +0000 Subject: [PATCH] Check POLLHUP if unable to read anything from network This solves a possible infinite loop that arises after commit e81895e . Commit e81895e prevents closing connections in case of temporary failures, but on the other side it doesn't allow to close faulty connections. --- lib/mysql_data_stream.cpp | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/lib/mysql_data_stream.cpp b/lib/mysql_data_stream.cpp index 5bfd876c1..3ff6e5da4 100644 --- a/lib/mysql_data_stream.cpp +++ b/lib/mysql_data_stream.cpp @@ -722,6 +722,12 @@ int MySQL_Data_Stream::read_from_net() { // it seems we end in shut_soft() anyway } } + if ( (revents & POLLHUP) ) { + // this is a final check + // Only if the amount of data read is 0 or less, then we check POLLHUP + proxy_debug(PROXY_DEBUG_NET, 5, "Session=%p, Datastream=%p -- shutdown soft. revents=%d , bytes read = %d\n", sess, this, revents, r); + shut_soft(); + } } else { queue_w(queueIN,r); bytes_info.bytes_recv+=r;