From: Willy Tarreau Date: Mon, 13 Sep 2021 08:07:38 +0000 (+0200) Subject: MINOR: applet: remove the thread mask from appctx_new() X-Git-Tag: v2.5-dev8~177 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=e61244631a76680330d37e3efa6aef7d4f9d62f9;p=thirdparty%2Fhaproxy.git MINOR: applet: remove the thread mask from appctx_new() 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. --- diff --git a/include/haproxy/applet.h b/include/haproxy/applet.h index 091b6991d3..717e017c5e 100644 --- a/include/haproxy/applet.h +++ b/include/haproxy/applet.h @@ -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(). is assigned as the applet, but it can be NULL. + * 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, 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; diff --git a/include/haproxy/stream_interface.h b/include/haproxy/stream_interface.h index cd26a51488..9492e82793 100644 --- a/include/haproxy/stream_interface.h +++ b/include/haproxy/stream_interface.h @@ -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; diff --git a/src/dns.c b/src/dns.c index d4bf83998e..bc3310a9ee 100644 --- 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; diff --git a/src/flt_spoe.c b/src/flt_spoe.c index 28a5a24f8d..f6e14d30c9 100644 --- a/src/flt_spoe.c +++ b/src/flt_spoe.c @@ -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); diff --git a/src/hlua.c b/src/hlua.c index 915356c09b..a158c46b4f 100644 --- a/src/hlua.c +++ b/src/hlua.c @@ -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; diff --git a/src/http_client.c b/src/http_client.c index 9f06ccc44d..debdee5d36 100644 --- a/src/http_client.c +++ b/src/http_client.c @@ -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; diff --git a/src/peers.c b/src/peers.c index 6a9b0df9e0..8af7475518 100644 --- a/src/peers.c +++ b/src/peers.c @@ -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; diff --git a/src/sink.c b/src/sink.c index 30dcfd5958..b869d2eafb 100644 --- a/src/sink.c +++ b/src/sink.c @@ -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;