mirror of
https://git.haproxy.org/git/haproxy.git/
synced 2025-08-07 23:56:57 +02:00
MINOR: applet: Add API to start applet on a thread subset
In the same way than for the tasks, the applets api was changed to be able to start a new appctx on a thread subset. For now the feature is disabled. Only appctx_new_here() is working. But it will be possible to start an appctx on a specific thread or a subset via a mask.
This commit is contained in:
parent
6712dc680c
commit
6095d57701
@ -40,10 +40,25 @@ int appctx_buf_available(void *arg);
|
|||||||
void *applet_reserve_svcctx(struct appctx *appctx, size_t size);
|
void *applet_reserve_svcctx(struct appctx *appctx, size_t size);
|
||||||
void appctx_shut(struct appctx *appctx);
|
void appctx_shut(struct appctx *appctx);
|
||||||
|
|
||||||
struct appctx *appctx_new(struct applet *applet, struct cs_endpoint *endp);
|
struct appctx *appctx_new(struct applet *applet, struct cs_endpoint *endp, unsigned long thread_mask);
|
||||||
int appctx_finalize_startup(struct appctx *appctx, struct proxy *px, struct buffer *input);
|
int appctx_finalize_startup(struct appctx *appctx, struct proxy *px, struct buffer *input);
|
||||||
void appctx_free_on_early_error(struct appctx *appctx);
|
void appctx_free_on_early_error(struct appctx *appctx);
|
||||||
|
|
||||||
|
static inline struct appctx *appctx_new_on(struct applet *applet, struct cs_endpoint *endp, uint thr)
|
||||||
|
{
|
||||||
|
return appctx_new(applet, endp, 1UL << thr);
|
||||||
|
}
|
||||||
|
|
||||||
|
static inline struct appctx *appctx_new_here(struct applet *applet, struct cs_endpoint *endp)
|
||||||
|
{
|
||||||
|
return appctx_new(applet, endp, tid_bit);
|
||||||
|
}
|
||||||
|
|
||||||
|
static inline struct appctx *appctx_new_anywhere(struct applet *applet, struct cs_endpoint *endp)
|
||||||
|
{
|
||||||
|
return appctx_new(applet, endp, MAX_THREADS_MASK);
|
||||||
|
}
|
||||||
|
|
||||||
/* Helper function to call .init applet callback function, if it exists. Returns 0
|
/* Helper function to call .init applet callback function, if it exists. Returns 0
|
||||||
* on success and -1 on error.
|
* on success and -1 on error.
|
||||||
*/
|
*/
|
||||||
|
@ -31,10 +31,13 @@ DECLARE_POOL(pool_head_appctx, "appctx", sizeof(struct appctx));
|
|||||||
* appctx_free(). <applet> is assigned as the applet, but it can be NULL. The
|
* appctx_free(). <applet> is assigned as the applet, but it can be NULL. The
|
||||||
* applet's task is always created on the current thread.
|
* applet's task is always created on the current thread.
|
||||||
*/
|
*/
|
||||||
struct appctx *appctx_new(struct applet *applet, struct cs_endpoint *endp)
|
struct appctx *appctx_new(struct applet *applet, struct cs_endpoint *endp, unsigned long thread_mask)
|
||||||
{
|
{
|
||||||
struct appctx *appctx;
|
struct appctx *appctx;
|
||||||
|
|
||||||
|
/* Disable the feature for now ! */
|
||||||
|
BUG_ON(thread_mask != tid_bit);
|
||||||
|
|
||||||
appctx = pool_zalloc(pool_head_appctx);
|
appctx = pool_zalloc(pool_head_appctx);
|
||||||
if (unlikely(!appctx))
|
if (unlikely(!appctx))
|
||||||
goto fail_appctx;
|
goto fail_appctx;
|
||||||
@ -53,7 +56,7 @@ struct appctx *appctx_new(struct applet *applet, struct cs_endpoint *endp)
|
|||||||
}
|
}
|
||||||
appctx->endp = endp;
|
appctx->endp = endp;
|
||||||
|
|
||||||
appctx->t = task_new_here();
|
appctx->t = task_new(thread_mask);
|
||||||
if (unlikely(!appctx->t))
|
if (unlikely(!appctx->t))
|
||||||
goto fail_task;
|
goto fail_task;
|
||||||
appctx->t->process = task_run_applet;
|
appctx->t->process = task_run_applet;
|
||||||
|
@ -476,7 +476,7 @@ struct appctx *cs_applet_create(struct conn_stream *cs, struct applet *app)
|
|||||||
|
|
||||||
DPRINTF(stderr, "registering handler %p for cs %p (was %p)\n", app, cs, cs_strm_task(cs));
|
DPRINTF(stderr, "registering handler %p for cs %p (was %p)\n", app, cs, cs_strm_task(cs));
|
||||||
|
|
||||||
appctx = appctx_new(app, cs->endp);
|
appctx = appctx_new_here(app, cs->endp);
|
||||||
if (!appctx)
|
if (!appctx)
|
||||||
return NULL;
|
return NULL;
|
||||||
cs_attach_applet(cs, appctx, appctx);
|
cs_attach_applet(cs, appctx, appctx);
|
||||||
|
@ -955,7 +955,7 @@ static struct appctx *dns_session_create(struct dns_session *ds)
|
|||||||
{
|
{
|
||||||
struct appctx *appctx;
|
struct appctx *appctx;
|
||||||
|
|
||||||
appctx = appctx_new(&dns_session_applet, NULL);
|
appctx = appctx_new_here(&dns_session_applet, NULL);
|
||||||
if (!appctx)
|
if (!appctx)
|
||||||
goto out_close;
|
goto out_close;
|
||||||
appctx->svcctx = (void *)ds;
|
appctx->svcctx = (void *)ds;
|
||||||
|
@ -2053,7 +2053,7 @@ spoe_create_appctx(struct spoe_config *conf)
|
|||||||
LIST_INIT(&spoe_appctx->waiting_queue);
|
LIST_INIT(&spoe_appctx->waiting_queue);
|
||||||
|
|
||||||
|
|
||||||
if ((appctx = appctx_new(&spoe_applet, NULL)) == NULL)
|
if ((appctx = appctx_new_here(&spoe_applet, NULL)) == NULL)
|
||||||
goto out_free_spoe_appctx;
|
goto out_free_spoe_appctx;
|
||||||
|
|
||||||
appctx->svcctx = spoe_appctx;
|
appctx->svcctx = spoe_appctx;
|
||||||
|
@ -2999,7 +2999,7 @@ __LJMP static int hlua_socket_new(lua_State *L)
|
|||||||
lua_setmetatable(L, -2);
|
lua_setmetatable(L, -2);
|
||||||
|
|
||||||
/* Create the applet context */
|
/* Create the applet context */
|
||||||
appctx = appctx_new(&update_applet, NULL);
|
appctx = appctx_new_here(&update_applet, NULL);
|
||||||
if (!appctx) {
|
if (!appctx) {
|
||||||
hlua_pusherror(L, "socket: out of memory");
|
hlua_pusherror(L, "socket: out of memory");
|
||||||
goto out_fail_conf;
|
goto out_fail_conf;
|
||||||
|
@ -538,7 +538,7 @@ struct appctx *httpclient_start(struct httpclient *hc)
|
|||||||
|
|
||||||
/* The HTTP client will be created in the same thread as the caller,
|
/* The HTTP client will be created in the same thread as the caller,
|
||||||
* avoiding threading issues */
|
* avoiding threading issues */
|
||||||
appctx = appctx_new(applet, NULL);
|
appctx = appctx_new_here(applet, NULL);
|
||||||
if (!appctx)
|
if (!appctx)
|
||||||
goto out;
|
goto out;
|
||||||
appctx->svcctx = hc;
|
appctx->svcctx = hc;
|
||||||
|
@ -3199,7 +3199,7 @@ static struct appctx *peer_session_create(struct peers *peers, struct peer *peer
|
|||||||
peer->statuscode = PEER_SESS_SC_CONNECTCODE;
|
peer->statuscode = PEER_SESS_SC_CONNECTCODE;
|
||||||
peer->last_hdshk = now_ms;
|
peer->last_hdshk = now_ms;
|
||||||
|
|
||||||
appctx = appctx_new(&peer_applet, NULL);
|
appctx = appctx_new_here(&peer_applet, NULL);
|
||||||
if (!appctx)
|
if (!appctx)
|
||||||
goto out_close;
|
goto out_close;
|
||||||
appctx->svcctx = (void *)peer;
|
appctx->svcctx = (void *)peer;
|
||||||
|
@ -673,7 +673,7 @@ static struct appctx *sink_forward_session_create(struct sink *sink, struct sink
|
|||||||
if (sft->srv->log_proto == SRV_LOG_PROTO_OCTET_COUNTING)
|
if (sft->srv->log_proto == SRV_LOG_PROTO_OCTET_COUNTING)
|
||||||
applet = &sink_forward_oc_applet;
|
applet = &sink_forward_oc_applet;
|
||||||
|
|
||||||
appctx = appctx_new(applet, NULL);
|
appctx = appctx_new_here(applet, NULL);
|
||||||
if (!appctx)
|
if (!appctx)
|
||||||
goto out_close;
|
goto out_close;
|
||||||
appctx->svcctx = (void *)sft;
|
appctx->svcctx = (void *)sft;
|
||||||
|
Loading…
Reference in New Issue
Block a user