mirror of
http://git.haproxy.org/git/haproxy.git/
synced 2025-02-19 20:27:01 +00:00
MEDIUM: lua: socket: add "socket" class for TCP I/O
This patch adds the TCP I/O functionnality. The class implemented provides the same functions than the "lua socket" project. This make network compatibility with another LUA project. The documentation is located here: http://w3.impa.br/~diego/software/luasocket/tcp.html
This commit is contained in:
parent
5b8608f1ed
commit
7e7ac32dad
@ -2,9 +2,14 @@
|
||||
#define _TYPES_HLUA_H
|
||||
|
||||
#include <lua.h>
|
||||
#include <lauxlib.h>
|
||||
|
||||
#include <types/proxy.h>
|
||||
#include <types/server.h>
|
||||
|
||||
#define CLASS_CORE "Core"
|
||||
#define CLASS_TXN "TXN"
|
||||
#define CLASS_SOCKET "Socket"
|
||||
|
||||
struct session;
|
||||
|
||||
@ -100,4 +105,12 @@ struct hlua_sleep {
|
||||
unsigned int wakeup_ms; /* hour to wakeup. */
|
||||
};
|
||||
|
||||
/* This struct is used to create coprocess doing TCP or
|
||||
* SSL I/O. It uses a fake session.
|
||||
*/
|
||||
struct hlua_socket {
|
||||
struct session *s; /* Session used for socket I/O. */
|
||||
luaL_Buffer b; /* buffer used to prepare strings. */
|
||||
};
|
||||
|
||||
#endif /* _TYPES_HLUA_H */
|
||||
|
@ -27,6 +27,9 @@
|
||||
|
||||
#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>
|
||||
|
||||
@ -150,6 +153,14 @@ struct appctx {
|
||||
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 */
|
||||
};
|
||||
|
||||
|
1122
src/hlua.c
1122
src/hlua.c
File diff suppressed because it is too large
Load Diff
Loading…
Reference in New Issue
Block a user