MINOR: applet: Change return value for .init callback function
0 is now returned on success and -1 on error.
diff --git a/addons/promex/service-prometheus.c b/addons/promex/service-prometheus.c
index 8422e54..9501b1c 100644
--- a/addons/promex/service-prometheus.c
+++ b/addons/promex/service-prometheus.c
@@ -1497,7 +1497,7 @@
{
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. */
diff --git a/include/haproxy/applet-t.h b/include/haproxy/applet-t.h
index 2784650..8e7eddb 100644
--- a/include/haproxy/applet-t.h
+++ b/include/haproxy/applet-t.h
@@ -46,8 +46,8 @@
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. */
diff --git a/src/hlua.c b/src/hlua.c
index 193956a..e323b9a 100644
--- a/src/hlua.c
+++ b/src/hlua.c
@@ -9226,7 +9226,7 @@
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 @@
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 @@
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 @@
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 @@
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 @@
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 @@
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 @@
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 @@
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 @@
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 @@
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 @@
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 @@
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 @@
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 @@
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 @@
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 @@
/* 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)