enum obj_type obj_type; /* object type = OBJ_TYPE_APPLET */
/* 3 unused bytes here */
char *name; /* applet's name to report in logs */
- int (*init)(struct appctx *); /* callback to init resources, may be NULL.
- expect 1 if ok, 0 if an error occurs, -1 if miss data. */
+ int (*init)(struct appctx *); /* callback to init resources, may be NULL.
+ expect 0 if ok, -1 if an error occurs. */
void (*fct)(struct appctx *); /* internal I/O handler, may never be NULL */
void (*release)(struct appctx *); /* callback to release resources, may be NULL */
unsigned int timeout; /* execution timeout. */
if (!hlua) {
SEND_ERR(strm->be, "Lua applet tcp '%s': out of memory.\n",
ctx->rule->arg.hlua_rule->fcn->name);
- return 0;
+ return -1;
}
HLUA_INIT(hlua);
tcp_ctx->hlua = hlua;
if (!task) {
SEND_ERR(strm->be, "Lua applet tcp '%s': out of memory.\n",
ctx->rule->arg.hlua_rule->fcn->name);
- return 0;
+ return -1;
}
task->nice = 0;
task->context = ctx;
if (!hlua_ctx_init(hlua, fcn_ref_to_stack_id(ctx->rule->arg.hlua_rule->fcn), task, 0)) {
SEND_ERR(strm->be, "Lua applet tcp '%s': can't initialize Lua context.\n",
ctx->rule->arg.hlua_rule->fcn->name);
- return 0;
+ return -1;
}
/* Set timeout according with the applet configuration. */
error = "critical error";
SEND_ERR(strm->be, "Lua applet tcp '%s': %s.\n",
ctx->rule->arg.hlua_rule->fcn->name, error);
- return 0;
+ return -1;
}
/* Check stack available size. */
SEND_ERR(strm->be, "Lua applet tcp '%s': full stack.\n",
ctx->rule->arg.hlua_rule->fcn->name);
RESET_SAFE_LJMP(hlua);
- return 0;
+ return -1;
}
/* Restore the function in the stack. */
SEND_ERR(strm->be, "Lua applet tcp '%s': full stack.\n",
ctx->rule->arg.hlua_rule->fcn->name);
RESET_SAFE_LJMP(hlua);
- return 0;
+ return -1;
}
hlua->nargs = 1;
SEND_ERR(strm->be, "Lua applet tcp '%s': full stack.\n",
ctx->rule->arg.hlua_rule->fcn->name);
RESET_SAFE_LJMP(hlua);
- return 0;
+ return -1;
}
lua_pushstring(hlua->T, *arg);
hlua->nargs++;
cs_cant_get(cs);
cs_rx_endp_more(cs);
- return 1;
+ return 0;
}
void hlua_applet_tcp_fct(struct appctx *ctx)
tcp_ctx->hlua = NULL;
}
-/* The function returns 1 if the initialisation is complete, 0 if
- * an errors occurs and -1 if more data are required for initializing
- * the applet. It also reserves the appctx for an hlua_http_ctx.
+/* The function returns 0 if the initialisation is complete or -1 if
+ * an errors occurs. It also reserves the appctx for an hlua_http_ctx.
*/
static int hlua_applet_http_init(struct appctx *ctx)
{
if (!hlua) {
SEND_ERR(strm->be, "Lua applet http '%s': out of memory.\n",
ctx->rule->arg.hlua_rule->fcn->name);
- return 0;
+ return -1;
}
HLUA_INIT(hlua);
http_ctx->hlua = hlua;
if (!task) {
SEND_ERR(strm->be, "Lua applet http '%s': out of memory.\n",
ctx->rule->arg.hlua_rule->fcn->name);
- return 0;
+ return -1;
}
task->nice = 0;
task->context = ctx;
if (!hlua_ctx_init(hlua, fcn_ref_to_stack_id(ctx->rule->arg.hlua_rule->fcn), task, 0)) {
SEND_ERR(strm->be, "Lua applet http '%s': can't initialize Lua context.\n",
ctx->rule->arg.hlua_rule->fcn->name);
- return 0;
+ return -1;
}
/* Set timeout according with the applet configuration. */
error = "critical error";
SEND_ERR(strm->be, "Lua applet http '%s': %s.\n",
ctx->rule->arg.hlua_rule->fcn->name, error);
- return 0;
+ return -1;
}
/* Check stack available size. */
SEND_ERR(strm->be, "Lua applet http '%s': full stack.\n",
ctx->rule->arg.hlua_rule->fcn->name);
RESET_SAFE_LJMP(hlua);
- return 0;
+ return -1;
}
/* Restore the function in the stack. */
SEND_ERR(strm->be, "Lua applet http '%s': full stack.\n",
ctx->rule->arg.hlua_rule->fcn->name);
RESET_SAFE_LJMP(hlua);
- return 0;
+ return -1;
}
hlua->nargs = 1;
SEND_ERR(strm->be, "Lua applet http '%s': full stack.\n",
ctx->rule->arg.hlua_rule->fcn->name);
RESET_SAFE_LJMP(hlua);
- return 0;
+ return -1;
}
lua_pushstring(hlua->T, *arg);
hlua->nargs++;
/* Wakeup the applet when data is ready for read. */
cs_cant_get(cs);
- return 1;
+ return 0;
}
void hlua_applet_http_fct(struct appctx *ctx)