mirror of
https://github.com/haproxy/haproxy.git
synced 2026-04-09 02:46:12 -04:00
This system permits to send signals between lua tasks. A main lua stack can register the signal in a coprocess. When the coprocess finish his job, it send a signal, and the associated task is wakes. If the main lua execution stack stop (with or without errors), the list or pending signals is purged.
42 lines
1.5 KiB
C
42 lines
1.5 KiB
C
#ifndef _TYPES_HLUA_H
|
|
#define _TYPES_HLUA_H
|
|
|
|
#include <lua.h>
|
|
|
|
enum hlua_state {
|
|
HLUA_STOP = 0,
|
|
HLUA_RUN,
|
|
};
|
|
|
|
enum hlua_exec {
|
|
HLUA_E_OK = 0,
|
|
HLUA_E_AGAIN, /* LUA yield, must resume the stack execution later, when
|
|
the associatedtask is waked. */
|
|
HLUA_E_ERRMSG, /* LUA stack execution failed with a string error message
|
|
in the top of stack. */
|
|
HLUA_E_ERR, /* LUA stack execution failed without error message. */
|
|
};
|
|
|
|
struct hlua {
|
|
lua_State *T; /* The LUA stack. */
|
|
int Tref; /* The reference of the stack in coroutine case.
|
|
-1 for the main lua stack. */
|
|
int Mref; /* The reference of the memory context in coroutine case.
|
|
-1 if the memory context is not used. */
|
|
int nargs; /* The number of arguments in the stack at the start of execution. */
|
|
enum hlua_state state; /* The current execution state. */
|
|
struct task *task; /* The task associated with the lua stack execution.
|
|
We must wake this task to continue the task execution */
|
|
struct list com; /* The list head of the signals attached to this task. */
|
|
struct ebpt_node node;
|
|
};
|
|
|
|
struct hlua_com {
|
|
struct list purge_me; /* Part of the list of signals to be purged in the
|
|
case of the LUA execution stack crash. */
|
|
struct list wake_me; /* Part of list of signals to be targeted if an
|
|
event occurs. */
|
|
struct task *task; /* The task to be wake if an event occurs. */
|
|
};
|
|
|
|
#endif /* _TYPES_HLUA_H */
|