void *applet_reserve_svcctx(struct appctx *appctx, size_t size);
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);
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
* on success and -1 on error.
*/
* 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 cs_endpoint *endp)
+struct appctx *appctx_new(struct applet *applet, struct cs_endpoint *endp, unsigned long thread_mask)
{
struct appctx *appctx;
+ /* Disable the feature for now ! */
+ BUG_ON(thread_mask != tid_bit);
+
appctx = pool_zalloc(pool_head_appctx);
if (unlikely(!appctx))
goto fail_appctx;
}
appctx->endp = endp;
- appctx->t = task_new_here();
+ appctx->t = task_new(thread_mask);
if (unlikely(!appctx->t))
goto fail_task;
appctx->t->process = task_run_applet;
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)
return NULL;
cs_attach_applet(cs, appctx, appctx);
{
struct appctx *appctx;
- appctx = appctx_new(&dns_session_applet, NULL);
+ appctx = appctx_new_here(&dns_session_applet, NULL);
if (!appctx)
goto out_close;
appctx->svcctx = (void *)ds;
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;
appctx->svcctx = spoe_appctx;
lua_setmetatable(L, -2);
/* Create the applet context */
- appctx = appctx_new(&update_applet, NULL);
+ appctx = appctx_new_here(&update_applet, NULL);
if (!appctx) {
hlua_pusherror(L, "socket: out of memory");
goto out_fail_conf;
/* The HTTP client will be created in the same thread as the caller,
* avoiding threading issues */
- appctx = appctx_new(applet, NULL);
+ appctx = appctx_new_here(applet, NULL);
if (!appctx)
goto out;
appctx->svcctx = hc;
peer->statuscode = PEER_SESS_SC_CONNECTCODE;
peer->last_hdshk = now_ms;
- appctx = appctx_new(&peer_applet, NULL);
+ appctx = appctx_new_here(&peer_applet, NULL);
if (!appctx)
goto out_close;
appctx->svcctx = (void *)peer;
if (sft->srv->log_proto == SRV_LOG_PROTO_OCTET_COUNTING)
applet = &sink_forward_oc_applet;
- appctx = appctx_new(applet, NULL);
+ appctx = appctx_new_here(applet, NULL);
if (!appctx)
goto out_close;
appctx->svcctx = (void *)sft;