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.
This commit is contained in:
Willy Tarreau 2021-09-13 10:07:38 +02:00
parent 87063a7da1
commit e61244631a
8 changed files with 11 additions and 10 deletions

View 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;

View 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;

View File

@ -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;

View 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);

View 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;

View 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;

View 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;

View 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;