/* Register an applet to handle a stream_interface as part of the * stream interface's owner task. The SI will wake it up everytime it * is solicited. The task's processing function must call the applet's * function before returning. It must be deleted by the task handler * using stream_int_unregister_handler(), possibly from within the * function itself. It also pre-initializes the applet's context and * returns it (or NULL in case it could not be allocated). */ struct appctx *stream_int_register_handler(struct stream_interface *si, struct si_applet *app) { struct appctx *appctx; DPRINTF(stderr, "registering handler %p for si %p (was %p)\n", app, si, si->owner); appctx = si_alloc_appctx(si); if (!appctx) return NULL; appctx_set_applet(appctx, app); si->flags |= SI_FL_WAIT_DATA; return si_appctx(si); }
/* Register an applet to handle a stream_interface as a new appctx. The SI will * wake it up everytime it is solicited. The appctx must be deleted by the task * handler using si_release_endpoint(), possibly from within the function itself. * It also pre-initializes the applet's context and returns it (or NULL in case * it could not be allocated). */ struct appctx *stream_int_register_handler(struct stream_interface *si, struct applet *app) { struct appctx *appctx; DPRINTF(stderr, "registering handler %p for si %p (was %p)\n", app, si, si_task(si)); appctx = si_alloc_appctx(si, app); if (!appctx) return NULL; si_applet_cant_get(si); appctx_wakeup(appctx); return si_appctx(si); }