From: Willy Tarreau Date: Thu, 8 Nov 2018 13:32:16 +0000 (+0100) Subject: BUG/MEDIUM: stream-int: don't wake up for nothing during SI_ST_CON X-Git-Tag: v1.9-dev6~21 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=b69f1713af2b7e99c31fc4726c5e1ef0058c9c9c;p=thirdparty%2Fhaproxy.git BUG/MEDIUM: stream-int: don't wake up for nothing during SI_ST_CON Commit eafd8ebcf ("MEDIUM: stream-int: call si_cs_process() in stream_int_update_conn") uncovered a sleeping bug. By calling si_cs_process() within si_update(), we end up calling stream_int_notify(). We rely on it to update the stream-int before quitting as a hack, but it happens to immediately wake the task up while the stream int's state is still SI_ST_CON (during the connection establishment). The observable effect is that an unreachable server causes haproxy to use 100% CPU until the connection timeout strikes. This patch fixes this by not causing the wake up for the SI_ST_CON state. It would equally be possible to check for states higher than SI_ST_EST as is done in other places, but for now better stay on the safe side by covering the only issue that can be triggered. It's suspected that this issue slightly affects older versions by causing one extra call to process_stream() during the connection setup for each activity change on the other side, but this should not have any observable effect. No backport is needed. --- diff --git a/src/stream_interface.c b/src/stream_interface.c index ce5c3a9bcd..e7b69cd28b 100644 --- a/src/stream_interface.c +++ b/src/stream_interface.c @@ -534,7 +534,7 @@ void stream_int_notify(struct stream_interface *si) /* wake the task up only when needed */ if (/* changes on the production side */ (ic->flags & (CF_READ_NULL|CF_READ_ERROR)) || - si->state != SI_ST_EST || + (si->state != SI_ST_EST && si->state != SI_ST_CON) || (si->flags & SI_FL_ERR) || ((ic->flags & CF_READ_PARTIAL) && (!ic->to_forward || si_opposite(si)->state != SI_ST_EST)) ||