From b4a92e7cb18cf6a41354af5316dc0d60b76051ce Mon Sep 17 00:00:00 2001 From: Christopher Faulet Date: Tue, 29 Jul 2025 08:51:40 +0200 Subject: [PATCH] MEDIUM: applet: Set .rcv_buf and .snd_buf functions on default ones if not set Based on the applet flags, it is possible to set .rcv_buf and .snd_buf callback functions if necessary. If these functions are not defined for an applet using the new API, it means the default functions must be used. We also take care to choose the raw version or the htx version, depending on the applet flags. --- src/applet.c | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/src/applet.c b/src/applet.c index e60ff8b18..edea10290 100644 --- a/src/applet.c +++ b/src/applet.c @@ -274,9 +274,20 @@ struct appctx *appctx_new_on(struct applet *applet, struct sedesc *sedesc, int t appctx->outbuf = BUF_NULL; appctx->to_forward = 0; - appctx->t->process = ((applet->flags & APPLET_FL_NEW_API) - ? task_process_applet - : task_run_applet); + if (applet->flags & APPLET_FL_NEW_API) { + appctx->t->process = task_process_applet; + /* Automatically set .rcv_buf and .snd_buf callback functions on default ones if not set */ + if (applet->rcv_buf == NULL) + applet->rcv_buf = (applet->flags & APPLET_FL_HTX + ? appctx_htx_rcv_buf + : appctx_raw_rcv_buf); + if (applet->snd_buf == NULL) + applet->snd_buf = (applet->flags & APPLET_FL_HTX + ? appctx_htx_snd_buf + : appctx_raw_snd_buf); + } + else + appctx->t->process = task_run_applet; appctx->t->context = appctx; LIST_INIT(&appctx->buffer_wait.list);