Skip to content

Commit

Permalink
Fix potential connector infinite loop in read_result::stop scenarios
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
ckreibich committed Dec 6, 2024
1 parent 96aaa14 commit e2d1d41
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion libbroker/broker/internal/connector.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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());
Expand Down

0 comments on commit e2d1d41

Please sign in to comment.