]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
MINOR: applet: remove the thread mask from appctx_new()
authorWilly Tarreau <w@1wt.eu>
Mon, 13 Sep 2021 08:07:38 +0000 (10:07 +0200)
committerWilly Tarreau <w@1wt.eu>
Fri, 17 Sep 2021 14:08:34 +0000 (16:08 +0200)
appctx_new() is exclusively called with tid_bit and it only uses the
mask to pass it to the accompanying task. There is no point requiring
the caller to know about a mask there, nor is there any point in
creating an applet outside of the context of its own thread anyway.
Let's drop this and pass tid_bit to task_new() directly.

include/haproxy/applet.h
include/haproxy/stream_interface.h
src/dns.c
src/flt_spoe.c
src/hlua.c
src/http_client.c
src/peers.c
src/sink.c

index 091b6991d311bcabc1bc057b8141e0f488357024..717e017c5edfb862631d36b6c29c14ec104861ea 100644 (file)
@@ -56,9 +56,10 @@ static inline void appctx_init(struct appctx *appctx)
 
 /* 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.
+ * 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, unsigned long thread_mask)
+static inline struct appctx *appctx_new(struct applet *applet)
 {
        struct appctx *appctx;
 
@@ -67,7 +68,7 @@ static inline struct appctx *appctx_new(struct applet *applet, unsigned long thr
                appctx->obj_type = OBJ_TYPE_APPCTX;
                appctx->applet = applet;
                appctx_init(appctx);
-               appctx->t = task_new(thread_mask);
+               appctx->t = task_new(tid_bit);
                if (unlikely(appctx->t == NULL)) {
                        pool_free(pool_head_appctx, appctx);
                        return NULL;
index cd26a51488b363873678c9ece340220ab4ef5b75..9492e82793c5b4e24f3643a29cf428f24e7d7b83 100644 (file)
@@ -407,7 +407,7 @@ static inline struct appctx *si_alloc_appctx(struct stream_interface *si, struct
        struct appctx *appctx;
 
        si_release_endpoint(si);
-       appctx = appctx_new(applet, tid_bit);
+       appctx = appctx_new(applet);
        if (appctx) {
                si_attach_appctx(si, appctx);
                appctx->t->nice = si_strm(si)->task->nice;
index d4bf83998e045f14971f5bed520dab97d2cf9592..bc3310a9eea6200aebe6222e6ff98e0279686d12 100644 (file)
--- a/src/dns.c
+++ b/src/dns.c
@@ -873,7 +873,7 @@ static struct appctx *dns_session_create(struct dns_session *ds)
        struct stream *s;
        struct applet *applet = &dns_session_applet;
 
-       appctx = appctx_new(applet, tid_bit);
+       appctx = appctx_new(applet);
        if (!appctx)
                goto out_close;
 
index 28a5a24f8d218db9768657a75a23a5a0a87920b2..f6e14d30c9c6a11dc2ddba1dd3c1d6113f801538 100644 (file)
@@ -1989,7 +1989,7 @@ spoe_create_appctx(struct spoe_config *conf)
        struct session     *sess;
        struct stream      *strm;
 
-       if ((appctx = appctx_new(&spoe_applet, tid_bit)) == NULL)
+       if ((appctx = appctx_new(&spoe_applet)) == NULL)
                goto out_error;
 
        appctx->ctx.spoe.ptr = pool_zalloc(pool_head_spoe_appctx);
index 915356c09b0cbc5e30aaf9c7934e4ebcffc66a5d..a158c46b4f4b1ea2868143fa0856816fb6838143 100644 (file)
@@ -2940,7 +2940,7 @@ __LJMP static int hlua_socket_new(lua_State *L)
        lua_setmetatable(L, -2);
 
        /* Create the applet context */
-       appctx = appctx_new(&update_applet, tid_bit);
+       appctx = appctx_new(&update_applet);
        if (!appctx) {
                hlua_pusherror(L, "socket: out of memory");
                goto out_fail_conf;
index 9f06ccc44dfceced9fb3962e1811d497bc7ffb56..debdee5d36be05f2fafbe4caebbd78a4087683e2 100644 (file)
@@ -341,7 +341,7 @@ struct appctx *httpclient_start(struct httpclient *hc)
 
        /* The HTTP client will be created in the same thread as the caller,
         * avoiding threading issues */
-       appctx = appctx_new(applet, tid_bit);
+       appctx = appctx_new(applet);
        if (!appctx)
                goto out;
 
index 6a9b0df9e0202a2fd6348466ec9a2ac3893a9d42..8af74755180de28fa92f21b3deab077243d51dac 100644 (file)
@@ -3183,7 +3183,7 @@ static struct appctx *peer_session_create(struct peers *peers, struct peer *peer
        peer->last_hdshk = now_ms;
        s = NULL;
 
-       appctx = appctx_new(&peer_applet, tid_bit);
+       appctx = appctx_new(&peer_applet);
        if (!appctx)
                goto out_close;
 
index 30dcfd59581b6b4fa9b4d1308d4cc9cebfad822a..b869d2eafb3bcfe3918ca0cb1a4951081ea2e689 100644 (file)
@@ -642,7 +642,7 @@ static struct appctx *sink_forward_session_create(struct sink *sink, struct sink
        if (sft->srv->log_proto == SRV_LOG_PROTO_OCTET_COUNTING)
                applet = &sink_forward_oc_applet;
 
-       appctx = appctx_new(applet, tid_bit);
+       appctx = appctx_new(applet);
        if (!appctx)
                goto out_close;