mirror of
https://git.haproxy.org/git/haproxy.git/
synced 2025-11-09 13:01:00 +01:00
MINOR: applet: do not put SE_FL_WANT_ROOM on rcv_buf() if the channel is empty
appctx_rcv_buf() prepares all the work to schedule the transfers between the applet and the channel, and it takes care of setting the various flags that indicate what condition is blocking the transfer from progressing. There is one limitation though. In case an applet refrains from sending data (e.g. rate-limited, prefers to aggregate blocks etc), it will leave a possibly empty channel buffer, and keep some data in its outbuf. The data in its outbuf will be seen by the function above as an indication of a channel full condition, so it will place SE_FL_WANT_ROOM. But later, sc_applet_recv() will see this flag with a possibly empty channel, and will rightfully trigger a BUG_ON(). appctx_rcv_buf() should be more accurate in fact. It should only set SE_FL_RCV_MORE when more data are present in the applet, then it should either set or clear SE_FL_WANT_ROOM dependingon whether the channel is empty or not. Right now it doesn't seem possible to trigger this condition in the current state of applets, but this will become possible with a future bugfix that will have to be backported, so this patch will need to be backported to 3.0.
This commit is contained in:
parent
259b1e1c18
commit
35106d65fb
14
src/applet.c
14
src/applet.c
@ -556,8 +556,18 @@ size_t appctx_rcv_buf(struct stconn *sc, struct buffer *buf, size_t count, unsig
|
||||
applet_fl_clr(appctx, APPCTX_FL_OUTBLK_FULL);
|
||||
|
||||
if (b_data(&appctx->outbuf)) {
|
||||
se_fl_set(appctx->sedesc, SE_FL_RCV_MORE | SE_FL_WANT_ROOM);
|
||||
TRACE_STATE("waiting for more room", APPLET_EV_RECV|APPLET_EV_BLK, appctx);
|
||||
se_fl_set(appctx->sedesc, SE_FL_RCV_MORE);
|
||||
if (b_data(buf)) {
|
||||
/* some data left with other data in the buffer often
|
||||
* means the applet couldn't write a block at once.
|
||||
*/
|
||||
se_fl_set(appctx->sedesc, SE_FL_WANT_ROOM);
|
||||
TRACE_STATE("waiting for more room", APPLET_EV_RECV|APPLET_EV_BLK, appctx);
|
||||
} else {
|
||||
/* the applet just doesn't want to give us partial data */
|
||||
se_fl_clr(appctx->sedesc, SE_FL_WANT_ROOM);
|
||||
TRACE_STATE("waiting for more data from applet", APPLET_EV_RECV|APPLET_EV_BLK, appctx);
|
||||
}
|
||||
}
|
||||
else {
|
||||
se_fl_clr(appctx->sedesc, SE_FL_RCV_MORE | SE_FL_WANT_ROOM);
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user