From d7467cd495d9f97667441256b1bc0b6e86f07cd8 Mon Sep 17 00:00:00 2001 From: Christopher Faulet Date: Tue, 6 Feb 2024 07:45:02 +0100 Subject: [PATCH] MINOR: applet: Identify applets using their own buffers via a flag These applets can now be identified by testing APPCTX_FL_INOUT_BUFS flag. This will be useful between the kind of applets in helper functions. --- include/haproxy/applet-t.h | 1 + src/applet.c | 13 ++++++++----- 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/include/haproxy/applet-t.h b/include/haproxy/applet-t.h index 9ee8f5d9cf..8360c85576 100644 --- a/include/haproxy/applet-t.h +++ b/include/haproxy/applet-t.h @@ -46,6 +46,7 @@ #define APPCTX_FL_ERROR 0x00000080 #define APPCTX_FL_SHUTDOWN 0x00000100 /* applet was shut down (->release() called if any). No more data exchange with SCs */ #define APPCTX_FL_WANT_DIE 0x00000200 /* applet was running and requested to die */ +#define APPCTX_FL_INOUT_BUFS 0x00000400 /* applet uses its own buffers */ struct appctx; struct proxy; diff --git a/src/applet.c b/src/applet.c index 362811718f..984ff2661b 100644 --- a/src/applet.c +++ b/src/applet.c @@ -260,17 +260,20 @@ struct appctx *appctx_new_on(struct applet *applet, struct sedesc *sedesc, int t } appctx->sedesc = sedesc; - if (applet->rcv_buf != NULL && applet->snd_buf != NULL) - appctx->t->process = task_process_applet; - else - appctx->t->process = task_run_applet; - appctx->t->context = appctx; appctx->flags = 0; appctx->inbuf = BUF_NULL; appctx->outbuf = BUF_NULL; appctx->to_forward = 0; + if (applet->rcv_buf != NULL && applet->snd_buf != NULL) { + appctx->t->process = task_process_applet; + appctx->flags |= APPCTX_FL_INOUT_BUFS; + } + else + appctx->t->process = task_run_applet; + appctx->t->context = appctx; + LIST_INIT(&appctx->buffer_wait.list); appctx->buffer_wait.target = appctx; appctx->buffer_wait.wakeup_cb = appctx_buf_available;