From: Christopher Faulet Date: Wed, 23 Mar 2022 10:46:56 +0000 (+0100) Subject: REORG: applet: Uninline appctx_new function X-Git-Tag: v2.6-dev6~100 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=cb2fa368e9998723111ad72c665faaa294646e72;p=thirdparty%2Fhaproxy.git REORG: applet: Uninline appctx_new function appctx_new() is moved in the C file and appctx_init() is now private. --- diff --git a/include/haproxy/applet.h b/include/haproxy/applet.h index 97b9c347b4..aa9124b3b3 100644 --- a/include/haproxy/applet.h +++ b/include/haproxy/applet.h @@ -36,52 +36,7 @@ extern struct pool_head *pool_head_appctx; struct task *task_run_applet(struct task *t, void *context, unsigned int state); int appctx_buf_available(void *arg); - -/* Initializes all required fields for a new appctx. Note that it does the - * minimum acceptable initialization for an appctx. This means only the - * 3 integer states st0, st1, st2 and the chunk used to gather unfinished - * commands are zeroed - */ -static inline void appctx_init(struct appctx *appctx) -{ - appctx->st0 = appctx->st1 = appctx->st2 = 0; - appctx->chunk = NULL; - appctx->io_release = NULL; - appctx->call_rate.curr_tick = 0; - appctx->call_rate.curr_ctr = 0; - appctx->call_rate.prev_ctr = 0; - appctx->state = 0; - LIST_INIT(&appctx->wait_entry); -} - -/* Tries to allocate a new appctx and initialize its main fields. The appctx - * is returned on success, NULL on failure. The appctx must be released using - * appctx_free(). is assigned as the applet, but it can be NULL. The - * applet's task is always created on the current thread. - */ -static inline struct appctx *appctx_new(struct applet *applet) -{ - struct appctx *appctx; - - appctx = pool_alloc(pool_head_appctx); - if (likely(appctx != NULL)) { - appctx->obj_type = OBJ_TYPE_APPCTX; - appctx->applet = applet; - appctx_init(appctx); - appctx->t = task_new_here(); - if (unlikely(appctx->t == NULL)) { - pool_free(pool_head_appctx, appctx); - return NULL; - } - 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; - _HA_ATOMIC_INC(&nb_applets); - } - return appctx; -} +struct appctx *appctx_new(struct applet *applet); /* Releases an appctx previously allocated by appctx_new(). */ static inline void __appctx_free(struct appctx *appctx) diff --git a/src/applet.c b/src/applet.c index ff7381da2d..f6fea74232 100644 --- a/src/applet.c +++ b/src/applet.c @@ -25,6 +25,52 @@ unsigned int nb_applets = 0; DECLARE_POOL(pool_head_appctx, "appctx", sizeof(struct appctx)); +/* Initializes all required fields for a new appctx. Note that it does the + * minimum acceptable initialization for an appctx. This means only the + * 3 integer states st0, st1, st2 and the chunk used to gather unfinished + * commands are zeroed + */ +static inline void appctx_init(struct appctx *appctx) +{ + appctx->st0 = appctx->st1 = appctx->st2 = 0; + appctx->chunk = NULL; + appctx->io_release = NULL; + appctx->call_rate.curr_tick = 0; + appctx->call_rate.curr_ctr = 0; + appctx->call_rate.prev_ctr = 0; + appctx->state = 0; + LIST_INIT(&appctx->wait_entry); +} + +/* Tries to allocate a new appctx and initialize its main fields. The appctx + * is returned on success, NULL on failure. The appctx must be released using + * appctx_free(). is assigned as the applet, but it can be NULL. The + * applet's task is always created on the current thread. + */ +struct appctx *appctx_new(struct applet *applet) +{ + struct appctx *appctx; + + appctx = pool_alloc(pool_head_appctx); + if (likely(appctx != NULL)) { + appctx->obj_type = OBJ_TYPE_APPCTX; + appctx->applet = applet; + appctx_init(appctx); + appctx->t = task_new_here(); + if (unlikely(appctx->t == NULL)) { + pool_free(pool_head_appctx, appctx); + return NULL; + } + 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; + _HA_ATOMIC_INC(&nb_applets); + } + return appctx; +} + /* Callback used to wake up an applet when a buffer is available. The applet * is woken up if an input buffer was requested for the associated * stream interface. In this case the buffer is immediately allocated and the