]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
REORG: applet: Uninline appctx_new function
authorChristopher Faulet <cfaulet@haproxy.com>
Wed, 23 Mar 2022 10:46:56 +0000 (11:46 +0100)
committerChristopher Faulet <cfaulet@haproxy.com>
Wed, 13 Apr 2022 13:10:14 +0000 (15:10 +0200)
appctx_new() is moved in the C file and appctx_init() is now private.

include/haproxy/applet.h
src/applet.c

index 97b9c347b4fe55530a2c92d46ccf0f6b31a51484..aa9124b3b3eb491cec6333c67238baed5744d224 100644 (file)
@@ -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(). <applet> 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)
index ff7381da2d3973aef19703aa6885d520df4ffd5c..f6fea7423231251ef27e06ac2817e58a48ddcfee 100644 (file)
@@ -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(). <applet> 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
  * <appctx> is woken up if an input buffer was requested for the associated
  * stream interface. In this case the buffer is immediately allocated and the