blob: 1241778114b027218f2b9f3b7f410ed4f337ebb6 [file] [log] [blame]
Thierry FOURNIER6f1fd482015-01-23 14:06:13 +01001#ifndef _TYPES_HLUA_H
2#define _TYPES_HLUA_H
3
4#include <lua.h>
5
Thierry FOURNIER2ba18a22015-01-23 14:07:08 +01006#define CLASS_CORE "Core"
Thierry FOURNIER65f34c62015-02-16 20:11:43 +01007#define CLASS_TXN "TXN"
8
9struct session;
Thierry FOURNIER2ba18a22015-01-23 14:07:08 +010010
Thierry FOURNIER380d0932015-01-23 14:27:52 +010011enum hlua_state {
12 HLUA_STOP = 0,
13 HLUA_RUN,
14};
15
16enum hlua_exec {
17 HLUA_E_OK = 0,
18 HLUA_E_AGAIN, /* LUA yield, must resume the stack execution later, when
19 the associatedtask is waked. */
20 HLUA_E_ERRMSG, /* LUA stack execution failed with a string error message
21 in the top of stack. */
22 HLUA_E_ERR, /* LUA stack execution failed without error message. */
23};
24
25struct hlua {
26 lua_State *T; /* The LUA stack. */
27 int Tref; /* The reference of the stack in coroutine case.
28 -1 for the main lua stack. */
29 int Mref; /* The reference of the memory context in coroutine case.
30 -1 if the memory context is not used. */
31 int nargs; /* The number of arguments in the stack at the start of execution. */
32 enum hlua_state state; /* The current execution state. */
33 struct task *task; /* The task associated with the lua stack execution.
34 We must wake this task to continue the task execution */
Thierry FOURNIER9ff7e6e2015-01-23 11:08:20 +010035 struct list com; /* The list head of the signals attached to this task. */
Thierry FOURNIER380d0932015-01-23 14:27:52 +010036 struct ebpt_node node;
37};
38
Thierry FOURNIER9ff7e6e2015-01-23 11:08:20 +010039struct hlua_com {
40 struct list purge_me; /* Part of the list of signals to be purged in the
41 case of the LUA execution stack crash. */
42 struct list wake_me; /* Part of list of signals to be targeted if an
43 event occurs. */
44 struct task *task; /* The task to be wake if an event occurs. */
45};
46
Thierry FOURNIERa4a0f3d2015-01-23 12:08:30 +010047/* This is a part of the list containing references to functions
48 * called at the initialisation time.
49 */
50struct hlua_init_function {
51 struct list l;
52 int function_ref;
53};
54
Thierry FOURNIER65f34c62015-02-16 20:11:43 +010055/* This struct contains the pointer provided on the most
56 * of internal HAProxy calls during the processing of
57 * rules, converters and sample-fetches. This struct is
58 * associated with the lua object called "TXN".
59 */
60struct hlua_txn {
61 struct session *s;
62 struct proxy *p;
63 void *l7;
64};
65
Thierry FOURNIERd0fa5382015-02-16 20:14:51 +010066/* This struct is used as a closure argument associated
67 * with dynamic sample-fetch created fucntions. This contains
68 * a pointer to the original sample_fetch struct. It is used
69 * to identify the function to execute with the sample fetch
70 * wrapper.
71 */
72struct hlua_sample_fetch {
73 struct sample_fetch *f;
74};
75
Thierry FOURNIER6f1fd482015-01-23 14:06:13 +010076#endif /* _TYPES_HLUA_H */