#ifndef _PROTO_HLUA_H
#define _PROTO_HLUA_H
+#ifdef USE_LUA
+
#include <lua.h>
#include <types/hlua.h>
+#define HLUA_INIT(__hlua) do { (__hlua)->T = 0; } while(0)
+
/* Lua HAProxy integration functions. */
void hlua_ctx_destroy(struct hlua *lua);
void hlua_init();
int hlua_post_init();
+#else /* USE_LUA */
+
+#define HLUA_INIT(__hlua)
+
+/* Empty function for compilation without Lua. */
+static inline void hlua_init() { }
+static inline int hlua_post_init() { return 1; }
+static inline void hlua_ctx_destroy() { }
+
+#endif /* USE_LUA */
+
#endif /* _PROTO_HLUA_H */
#ifndef _TYPES_HLUA_H
#define _TYPES_HLUA_H
+#ifdef USE_LUA
+
#include <lua.h>
#include <lauxlib.h>
struct channel *chn;
};
+#else /* USE_LUA */
+
+/* Empty struct for compilation compatibility */
+struct hlua { };
+struct hlua_socket { };
+
+#endif /* USE_LUA */
+
#endif /* _TYPES_HLUA_H */
#include <types/channel.h>
#include <types/compression.h>
-
-#ifdef USE_LUA
#include <types/hlua.h>
-#endif
#include <types/obj_type.h>
#include <types/proto_http.h>
#include <types/proxy.h>
struct list *current_rule_list; /* this is used to store the current executed rule list. */
struct list *current_rule; /* this is used to store the current rule to be resumed. */
-#ifdef USE_LUA
struct hlua hlua; /* lua runtime context */
-#endif
};
#endif /* _TYPES_SESSION_H */
#include <types/channel.h>
#include <types/connection.h>
-#ifdef USE_LUA
#include <types/hlua.h>
-#endif
#include <types/obj_type.h>
#include <common/config.h>
struct pattern_expr *expr;
struct chunk chunk;
} map;
-#ifdef USE_LUA
struct {
int connected;
struct hlua_socket *socket;
struct list wake_on_read;
struct list wake_on_write;
} hlua;
-#endif
} ctx; /* used by stats I/O handlers to dump the stats */
};
#include <proto/connection.h>
#include <proto/fd.h>
#include <proto/hdr_idx.h>
-#ifdef USE_LUA
#include <proto/hlua.h>
-#endif
#include <proto/listener.h>
#include <proto/log.h>
#include <proto/pattern.h>
init_pendconn();
init_proto_http();
-#ifdef USE_LUA
/* Initialise lua. */
hlua_init();
-#endif
global.tune.options |= GTUNE_USE_SELECT; /* select() is always available */
#if defined(ENABLE_POLL)
if (!global.node)
global.node = strdup(hostname);
-#ifdef USE_LUA
if (!hlua_post_init())
exit(1);
-#endif
}
static void deinit_acl_cond(struct acl_cond *cond)
*/
void hlua_ctx_destroy(struct hlua *lua)
{
+ if (!lua->T)
+ return;
+
/* Remove context. */
hlua_delhlua(lua);
#include <proto/freq_ctr.h>
#include <proto/frontend.h>
#include <proto/hdr_idx.h>
-#ifdef USE_LUA
#include <proto/hlua.h>
-#endif
#include <proto/listener.h>
#include <proto/log.h>
#include <proto/raw_sock.h>
txn->req.chn = s->req;
txn->rsp.chn = s->rep;
-#ifdef USE_LUA
- s->hlua.T = NULL;
-#endif
+ HLUA_INIT(&s->hlua);
/* finish initialization of the accepted file descriptor */
conn_data_want_recv(conn);
if (!LIST_ISEMPTY(&buffer_wq))
session_offer_buffers();
-#ifdef USE_LUA
- if (s->hlua.T)
- hlua_ctx_destroy(&s->hlua);
-#endif
+ hlua_ctx_destroy(&s->hlua);
pool_free2(pool2_channel, s->req);
pool_free2(pool2_channel, s->rep);