:returns: A socket class object.
+.. js:function:: core.done(data)
+
+ **context**: body, init, task, action, sample-fetch, converter
+
+ :param any data: Return some data for the caller. It is useful with
+ sample-fetches and sample-converters.
+
+ Immediately stops the current Lua execution and returns to the caller which
+ may be a sample fetch, a converter or an action and returns the specified
+ value (ignored for actions). It is used when the LUA process finishes its
+ work and wants to give back the control to HAProxy without executing the
+ remaining code. It can be seen as a multi-level "return".
+
.. js:function:: core.yield()
**context**: task, action, sample-fetch, converter
#define HLUA_CTRLYIELD 0x00000002
#define HLUA_WAKERESWR 0x00000004
#define HLUA_WAKEREQWR 0x00000008
+#define HLUA_EXIT 0x00000010
enum hlua_exec {
HLUA_E_OK = 0,
break;
case LUA_ERRRUN:
+
+ /* Special exit case. The traditionnal exit is returned as an error
+ * because the errors ares the only one mean to return immediately
+ * from and lua execution.
+ */
+ if (lua->flags & HLUA_EXIT) {
+ ret = HLUA_E_OK;
+ break;
+ }
+
lua->wake_time = TICK_ETERNITY;
if (!lua_checkstack(lua->T, 1)) {
ret = HLUA_E_ERR;
return ret;
}
+/* This function exit the current code. */
+__LJMP static int hlua_done(lua_State *L)
+{
+ struct hlua *hlua = hlua_gethlua(L);
+
+ hlua->flags |= HLUA_EXIT;
+ WILL_LJMP(lua_error(L));
+
+ return 0;
+}
+
/* This function is an LUA binding. It provides a function
* for deleting ACL from a referenced ACL file.
*/
hlua_class_function(gL.T, "Info", hlua_log_info);
hlua_class_function(gL.T, "Warning", hlua_log_warning);
hlua_class_function(gL.T, "Alert", hlua_log_alert);
+ hlua_class_function(gL.T, "done", hlua_done);
lua_setglobal(gL.T, "core");