From e2d1d413b838b121206c085642e1b45fcdfa76f3 Mon Sep 17 00:00:00 2001 From: Christian Kreibich Date: Mon, 2 Dec 2024 14:39:14 -0800 Subject: [PATCH] Fix potential connector infinite loop in read_result::stop scenarios When connect_manager::continue_reading() encounters a read_result::stop, it clears the read mask, indicating no more reads should happen, but this flag isn't checked in connector::run_impl()'s while loop. This could lead to infinite 100% CPU utilization in a tight loop. We now simply consult the read mask in addition to the other checks. --- libbroker/broker/internal/connector.cc | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/libbroker/broker/internal/connector.cc b/libbroker/broker/internal/connector.cc index 603e1d5c..d0d4b4c5 100644 --- a/libbroker/broker/internal/connector.cc +++ b/libbroker/broker/internal/connector.cc @@ -1944,7 +1944,8 @@ void connector::run_impl(listener* sub, shared_filter_type* filter) { } else { mgr.abort(*i); } - while ((i->revents & read_mask) && mgr.must_read_more(*i)) + while ((i->revents & read_mask) && (i->events & read_mask) + && mgr.must_read_more(*i)) mgr.continue_reading(*i); } } while (--presult > 0 && advance());