void *applet_reserve_svcctx(struct appctx *appctx, size_t size);
void appctx_shut(struct appctx *appctx);
-struct appctx *appctx_new(struct applet *applet, struct sedesc *sedesc, unsigned long thread_mask);
+struct appctx *appctx_new_on(struct applet *applet, struct sedesc *sedesc, int thr);
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 sedesc *sedesc, uint thr)
-{
- return appctx_new(applet, sedesc, 1UL << thr);
-}
-
static inline struct appctx *appctx_new_here(struct applet *applet, struct sedesc *sedesc)
{
- return appctx_new(applet, sedesc, tid_bit);
+ return appctx_new_on(applet, sedesc, tid);
}
static inline struct appctx *appctx_new_anywhere(struct applet *applet, struct sedesc *sedesc)
{
- return appctx_new(applet, sedesc, all_threads_mask);
+ return appctx_new_on(applet, sedesc, -1);
}
/* Helper function to call .init applet callback function, if it exists. Returns 0
/* Tries to allocate a new appctx and initialize all of its 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. The
- * applet's task is always created on the current thread.
+ * appctx_free(). <applet> is assigned as the applet, but it can be NULL. <thr>
+ * is the thread ID to start the applet on, and a negative value allows the
+ * applet to start anywhere. Backend applets may only be created on the current
+ * thread.
*/
-struct appctx *appctx_new(struct applet *applet, struct sedesc *sedesc, unsigned long thread_mask)
+struct appctx *appctx_new_on(struct applet *applet, struct sedesc *sedesc, int thr)
{
struct appctx *appctx;
/* Backend appctx cannot be started on another thread than the local one */
- BUG_ON(thread_mask != tid_bit && sedesc);
+ BUG_ON(thr != tid && sedesc);
appctx = pool_zalloc(pool_head_appctx);
if (unlikely(!appctx))
}
appctx->sedesc = sedesc;
- appctx->t = task_new(thread_mask);
+ if (thr >= 0)
+ appctx->t = task_new_on(thr);
+ else
+ appctx->t = task_new_anywhere();
+
if (unlikely(!appctx->t))
goto fail_task;
appctx->t->process = task_run_applet;