lua->run_time += now_ms - lua->start_time;
if (lua->max_time && lua->run_time > lua->max_time) {
lua_settop(lua->T, 0); /* Empty the stack. */
- if (!lua_checkstack(lua->T, 1)) {
- ret = HLUA_E_ERR;
- break;
- }
- lua_pushfstring(lua->T, "execution timeout");
- ret = HLUA_E_ERRMSG;
+ ret = HLUA_E_ETMOUT;
break;
}
/* Process the forced yield. if the general yield is not allowed or
}
if (!yield_allowed) {
lua_settop(lua->T, 0); /* Empty the stack. */
- if (!lua_checkstack(lua->T, 1)) {
- ret = HLUA_E_ERR;
- break;
- }
- lua_pushfstring(lua->T, "yield not allowed");
- ret = HLUA_E_ERRMSG;
+ ret = HLUA_E_YIELD;
break;
}
ret = HLUA_E_AGAIN;
case LUA_ERRMEM:
lua->wake_time = TICK_ETERNITY;
lua_settop(lua->T, 0); /* Empty the stack. */
- if (!lua_checkstack(lua->T, 1)) {
- ret = HLUA_E_ERR;
- break;
- }
- lua_pushfstring(lua->T, "out of memory error");
- ret = HLUA_E_ERRMSG;
+ ret = HLUA_E_NOMEM;
break;
case LUA_ERRERR:
default:
lua->wake_time = TICK_ETERNITY;
lua_settop(lua->T, 0); /* Empty the stack. */
- if (!lua_checkstack(lua->T, 1)) {
- ret = HLUA_E_ERR;
- break;
- }
- lua_pushfstring(lua->T, "unknonwn error");
- ret = HLUA_E_ERRMSG;
+ ret = HLUA_E_ERR;
break;
}
HLUA_CLR_RUN(lua);
break;
+ case HLUA_E_ETMOUT:
+ case HLUA_E_NOMEM:
+ case HLUA_E_YIELD:
case HLUA_E_ERR:
HLUA_CLR_RUN(lua);
notification_purge(&lua->com);
lua_pop(stream->hlua->T, 1);
return 0;
+ case HLUA_E_ETMOUT:
+ SEND_ERR(stream->be, "Lua converter '%s': execution timeout.\n", fcn->name);
+ return 0;
+
+ case HLUA_E_NOMEM:
+ SEND_ERR(stream->be, "Lua converter '%s': out of memory error.\n", fcn->name);
+ return 0;
+
+ case HLUA_E_YIELD:
+ SEND_ERR(stream->be, "Lua converter '%s': yield functions like core.tcp() or core.sleep() are not allowed.\n", fcn->name);
+ return 0;
+
case HLUA_E_ERR:
/* Display log. */
SEND_ERR(stream->be, "Lua converter '%s' returns an unknown error.\n", fcn->name);
lua_pop(stream->hlua->T, 1);
return 0;
+ case HLUA_E_ETMOUT:
+ if (!consistency_check(stream, smp->opt, &stream->hlua->cons))
+ stream_int_retnclose(&stream->si[0], &msg);
+ SEND_ERR(smp->px, "Lua sample-fetch '%s': execution timeout.\n", fcn->name);
+ return 0;
+
+ case HLUA_E_NOMEM:
+ if (!consistency_check(stream, smp->opt, &stream->hlua->cons))
+ stream_int_retnclose(&stream->si[0], &msg);
+ SEND_ERR(smp->px, "Lua sample-fetch '%s': out of memory error.\n", fcn->name);
+ return 0;
+
+ case HLUA_E_YIELD:
+ if (!consistency_check(stream, smp->opt, &stream->hlua->cons))
+ stream_int_retnclose(&stream->si[0], &msg);
+ SEND_ERR(smp->px, "Lua sample-fetch '%s': yield not allowed.\n", fcn->name);
+ return 0;
+
case HLUA_E_ERR:
if (!consistency_check(stream, smp->opt, &stream->hlua->cons))
stream_int_retnclose(&stream->si[0], &msg);
lua_pop(s->hlua->T, 1);
return ACT_RET_CONT;
+ case HLUA_E_ETMOUT:
+ if (!consistency_check(s, dir, &s->hlua->cons)) {
+ stream_int_retnclose(&s->si[0], &msg);
+ return ACT_RET_ERR;
+ }
+ SEND_ERR(px, "Lua function '%s': execution timeout.\n", rule->arg.hlua_rule->fcn.name);
+ return 0;
+
+ case HLUA_E_NOMEM:
+ if (!consistency_check(s, dir, &s->hlua->cons)) {
+ stream_int_retnclose(&s->si[0], &msg);
+ return ACT_RET_ERR;
+ }
+ SEND_ERR(px, "Lua function '%s': out of memory error.\n", rule->arg.hlua_rule->fcn.name);
+ return 0;
+
+ case HLUA_E_YIELD:
+ if (!consistency_check(s, dir, &s->hlua->cons)) {
+ stream_int_retnclose(&s->si[0], &msg);
+ return ACT_RET_ERR;
+ }
+ SEND_ERR(px, "Lua function '%s': aborting Lua processing on expired timeout.\n",
+ rule->arg.hlua_rule->fcn.name);
+ return 0;
+
case HLUA_E_ERR:
if (!consistency_check(s, dir, &s->hlua->cons)) {
stream_int_retnclose(&s->si[0], &msg);
lua_pop(hlua->T, 1);
goto error;
+ case HLUA_E_ETMOUT:
+ SEND_ERR(px, "Lua applet tcp '%s': execution timeout.\n",
+ rule->arg.hlua_rule->fcn.name);
+ goto error;
+
+ case HLUA_E_NOMEM:
+ SEND_ERR(px, "Lua applet tcp '%s': out of memory error.\n",
+ rule->arg.hlua_rule->fcn.name);
+ goto error;
+
+ case HLUA_E_YIELD: /* unexpected */
+ SEND_ERR(px, "Lua applet tcp '%s': yield not allowed.\n",
+ rule->arg.hlua_rule->fcn.name);
+ goto error;
+
case HLUA_E_ERR:
/* Display log. */
SEND_ERR(px, "Lua applet tcp '%s' return an unknown error.\n",
lua_pop(hlua->T, 1);
goto error;
+ case HLUA_E_ETMOUT:
+ SEND_ERR(px, "Lua applet http '%s': execution timeout.\n",
+ rule->arg.hlua_rule->fcn.name);
+ goto error;
+
+ case HLUA_E_NOMEM:
+ SEND_ERR(px, "Lua applet http '%s': out of memory error.\n",
+ rule->arg.hlua_rule->fcn.name);
+ goto error;
+
+ case HLUA_E_YIELD: /* unexpected */
+ SEND_ERR(px, "Lua applet http '%s': yield not allowed.\n",
+ rule->arg.hlua_rule->fcn.name);
+ goto error;
+
case HLUA_E_ERR:
/* Display log. */
SEND_ERR(px, "Lua applet http '%s' return an unknown error.\n",
lua_pop(hlua->T, 1);
return 1;
+ case HLUA_E_ETMOUT:
+ SEND_ERR(NULL, "Lua converter '%s': execution timeout.\n",
+ fcn->name);
+ return 1;
+
+ case HLUA_E_NOMEM:
+ SEND_ERR(NULL, "Lua converter '%s': out of memory error.\n",
+ fcn->name);
+ return 1;
+
+ case HLUA_E_YIELD: /* unexpected */
+ SEND_ERR(NULL, "Lua converter '%s': yield not allowed.\n",
+ fcn->name);
+ return 1;
+
case HLUA_E_ERR:
/* Display log. */
SEND_ERR(NULL, "Lua cli '%s' return an unknown error.\n",