mirror of
http://git.haproxy.org/git/haproxy.git/
synced 2024-12-27 23:22:09 +00:00
MINOR: applet: Change return value for .init callback function
0 is now returned on success and -1 on error.
This commit is contained in:
parent
92202da2da
commit
c9929380a4
@ -1497,7 +1497,7 @@ static int promex_appctx_init(struct appctx *appctx)
|
||||
{
|
||||
applet_reserve_svcctx(appctx, sizeof(struct promex_ctx));
|
||||
appctx->st0 = PROMEX_ST_INIT;
|
||||
return 1;
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* The main I/O handler for the promex applet. */
|
||||
|
@ -46,8 +46,8 @@ struct applet {
|
||||
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. */
|
||||
|
37
src/hlua.c
37
src/hlua.c
@ -9226,7 +9226,7 @@ static int hlua_applet_tcp_init(struct appctx *ctx)
|
||||
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;
|
||||
@ -9237,7 +9237,7 @@ static int hlua_applet_tcp_init(struct appctx *ctx)
|
||||
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;
|
||||
@ -9252,7 +9252,7 @@ static int hlua_applet_tcp_init(struct appctx *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. */
|
||||
@ -9266,7 +9266,7 @@ static int hlua_applet_tcp_init(struct appctx *ctx)
|
||||
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. */
|
||||
@ -9274,7 +9274,7 @@ static int hlua_applet_tcp_init(struct appctx *ctx)
|
||||
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. */
|
||||
@ -9285,7 +9285,7 @@ static int hlua_applet_tcp_init(struct appctx *ctx)
|
||||
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;
|
||||
|
||||
@ -9295,7 +9295,7 @@ static int hlua_applet_tcp_init(struct appctx *ctx)
|
||||
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++;
|
||||
@ -9307,7 +9307,7 @@ static int hlua_applet_tcp_init(struct appctx *ctx)
|
||||
cs_cant_get(cs);
|
||||
cs_rx_endp_more(cs);
|
||||
|
||||
return 1;
|
||||
return 0;
|
||||
}
|
||||
|
||||
void hlua_applet_tcp_fct(struct appctx *ctx)
|
||||
@ -9400,9 +9400,8 @@ static void hlua_applet_tcp_release(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)
|
||||
{
|
||||
@ -9420,7 +9419,7 @@ 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;
|
||||
@ -9435,7 +9434,7 @@ static int hlua_applet_http_init(struct appctx *ctx)
|
||||
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;
|
||||
@ -9450,7 +9449,7 @@ static int hlua_applet_http_init(struct appctx *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. */
|
||||
@ -9464,7 +9463,7 @@ static int hlua_applet_http_init(struct appctx *ctx)
|
||||
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. */
|
||||
@ -9472,7 +9471,7 @@ static int hlua_applet_http_init(struct appctx *ctx)
|
||||
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. */
|
||||
@ -9483,7 +9482,7 @@ static int hlua_applet_http_init(struct appctx *ctx)
|
||||
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;
|
||||
|
||||
@ -9493,7 +9492,7 @@ static int hlua_applet_http_init(struct appctx *ctx)
|
||||
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++;
|
||||
@ -9504,7 +9503,7 @@ static int hlua_applet_http_init(struct appctx *ctx)
|
||||
/* 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)
|
||||
|
Loading…
Reference in New Issue
Block a user