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.
This commit is contained in:
Christopher Faulet 2024-02-06 07:45:02 +01:00
parent a9301c96f1
commit d7467cd495
2 changed files with 9 additions and 5 deletions

View File

@ -46,6 +46,7 @@
#define APPCTX_FL_ERROR 0x00000080 #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_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_WANT_DIE 0x00000200 /* applet was running and requested to die */
#define APPCTX_FL_INOUT_BUFS 0x00000400 /* applet uses its own buffers */
struct appctx; struct appctx;
struct proxy; struct proxy;

View File

@ -260,17 +260,20 @@ struct appctx *appctx_new_on(struct applet *applet, struct sedesc *sedesc, int t
} }
appctx->sedesc = sedesc; 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->flags = 0;
appctx->inbuf = BUF_NULL; appctx->inbuf = BUF_NULL;
appctx->outbuf = BUF_NULL; appctx->outbuf = BUF_NULL;
appctx->to_forward = 0; 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); LIST_INIT(&appctx->buffer_wait.list);
appctx->buffer_wait.target = appctx; appctx->buffer_wait.target = appctx;
appctx->buffer_wait.wakeup_cb = appctx_buf_available; appctx->buffer_wait.wakeup_cb = appctx_buf_available;