]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
MEDIUM: applet: Set .rcv_buf and .snd_buf functions on default ones if not set
authorChristopher Faulet <cfaulet@haproxy.com>
Tue, 29 Jul 2025 06:51:40 +0000 (08:51 +0200)
committerChristopher Faulet <cfaulet@haproxy.com>
Mon, 25 Aug 2025 09:11:05 +0000 (11:11 +0200)
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

index e60ff8b18b1a6f6bb705914d63de81f5bd250b60..edea102901c8750c098f22ce7084d4684ac1505a 100644 (file)
@@ -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);