From: Christopher Faulet Date: Tue, 20 Feb 2024 07:29:50 +0000 (+0100) Subject: MINOR: applet: Let's applets .snd_buf function deal with full input buffers X-Git-Tag: v3.0-dev7~55 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=a933569b52aa73d6ba271b1790f5ecc700be5b8c;p=thirdparty%2Fhaproxy.git MINOR: applet: Let's applets .snd_buf function deal with full input buffers It is now the responsbility of applets .snd_buf callback function to notify the input buffer is full. This will allow the applets to not consume all data waiting for more data. Of course, it is only useful for applets using a custom .snd_buf callback function. --- diff --git a/src/applet.c b/src/applet.c index 90aa89f5da..8e7ac445b7 100644 --- a/src/applet.c +++ b/src/applet.c @@ -593,14 +593,25 @@ size_t appctx_htx_snd_buf(struct appctx *appctx, struct buffer *buf, size_t coun htx_to_buf(appctx_htx, &appctx->outbuf); htx_to_buf(buf_htx, buf); ret -= buf_htx->data; - end: + if (ret < count) { + applet_fl_set(appctx, APPCTX_FL_INBLK_FULL); + TRACE_STATE("report appctx inbuf is full", APPLET_EV_SEND|APPLET_EV_BLK, appctx); + } return ret; } size_t appctx_raw_snd_buf(struct appctx *appctx, struct buffer *buf, size_t count, unsigned flags) { - return b_xfer(&appctx->inbuf, buf, MIN(b_room(&appctx->inbuf), count)); + size_t ret = 0; + + ret = b_xfer(&appctx->inbuf, buf, MIN(b_room(&appctx->inbuf), count)); + if (ret < count) { + applet_fl_set(appctx, APPCTX_FL_INBLK_FULL); + TRACE_STATE("report appctx inbuf is full", APPLET_EV_SEND|APPLET_EV_BLK, appctx); + } + end: + return ret; } size_t appctx_snd_buf(struct stconn *sc, struct buffer *buf, size_t count, unsigned int flags) @@ -616,21 +627,16 @@ size_t appctx_snd_buf(struct stconn *sc, struct buffer *buf, size_t count, unsig if (applet_fl_test(appctx, (APPCTX_FL_INBLK_FULL|APPCTX_FL_INBLK_ALLOC))) goto end; + if (!count) + goto end; + if (!appctx_get_buf(appctx, &appctx->inbuf)) { applet_fl_set(appctx, APPCTX_FL_INBLK_ALLOC); TRACE_STATE("waiting for appctx inbuf allocation", APPLET_EV_SEND|APPLET_EV_BLK, appctx); goto end; } - if (!count) - goto end; - ret = appctx->applet->snd_buf(appctx, buf, count, flags); - if (ret < count) { - applet_fl_set(appctx, APPCTX_FL_INBLK_FULL); - appctx_wakeup(appctx); - TRACE_STATE("report appctx inbuf is full", APPLET_EV_SEND|APPLET_EV_BLK, appctx); - } end: if (applet_fl_test(appctx, (APPCTX_FL_ERROR|APPCTX_FL_ERR_PENDING))) {