From 96aadd5c552e26e90453a8caa636d00afc777828 Mon Sep 17 00:00:00 2001 From: Willy Tarreau Date: Wed, 7 Nov 2018 11:55:54 +0100 Subject: [PATCH] MEDIUM: stream-int: temporarily make si_chk_rcv() take care of SI_FL_WAIT_ROOM This flag should already be cleared before calling the *chk_rcv() functions. Before adapting all call places, let's first make sure si_chk_rcv() clears it before calling them so that these functions do not have to check it again and so that they do not adjust it. This function will only call the lower layers if the SI_FL_WANT_PUT flag is present so that the endpoint can decide not to be called (as done with applets). --- include/proto/stream_interface.h | 10 +++++++++- src/stream_interface.c | 5 ----- 2 files changed, 9 insertions(+), 6 deletions(-) diff --git a/include/proto/stream_interface.h b/include/proto/stream_interface.h index 7bab7ffd0..a687b2ac6 100644 --- a/include/proto/stream_interface.h +++ b/include/proto/stream_interface.h @@ -385,9 +385,17 @@ static inline void si_update(struct stream_interface *si) si->ops->update(si); } -/* Calls chk_rcv on the connection using the data layer */ +/* This is to be used after making some room available in a channel. It will + * clear SI_FL_WAIT_ROOM, then if SI_FL_WANT_PUT is set, will calls ->chk_rcv() + * to enable receipt of new data. + */ static inline void si_chk_rcv(struct stream_interface *si) { + si->flags &= ~SI_FL_WAIT_ROOM; + + if (!(si->flags & SI_FL_WANT_PUT)) + return; + si->ops->chk_rcv(si); } diff --git a/src/stream_interface.c b/src/stream_interface.c index b0ccf9e97..ad9ff9efd 100644 --- a/src/stream_interface.c +++ b/src/stream_interface.c @@ -257,7 +257,6 @@ static void stream_int_chk_rcv(struct stream_interface *si) } else { /* (re)start reading */ - si->flags &= ~SI_FL_WAIT_ROOM; tasklet_wakeup(si->wait_event.task); if (!(si->flags & SI_FL_DONT_WAKE)) task_wakeup(si_task(si), TASK_WOKEN_IO); @@ -970,7 +969,6 @@ static void stream_int_chk_rcv_conn(struct stream_interface *si) } else { /* (re)start reading */ - si->flags &= ~SI_FL_WAIT_ROOM; tasklet_wakeup(si->wait_event.task); } } @@ -1502,9 +1500,6 @@ static void stream_int_chk_rcv_applet(struct stream_interface *si) if (unlikely(si->state != SI_ST_EST || (ic->flags & (CF_SHUTR|CF_DONT_READ)))) return; - /* here we only wake the applet up if it was waiting for some room */ - if (!(si->flags & SI_FL_WAIT_ROOM)) - return; if (channel_may_recv(ic) && !ic->pipe) { /* (re)start reading */