Skip to content

feature: cosockets nonblocking listen accept feature #1393

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1,417 changes: 1,383 additions & 34 deletions src/ngx_http_lua_socket_tcp.c

Large diffs are not rendered by default.

22 changes: 22 additions & 0 deletions src/ngx_http_lua_socket_tcp.h
Original file line number Diff line number Diff line change
@@ -22,6 +22,9 @@
#define NGX_HTTP_LUA_SOCKET_FT_SSL 0x0100


typedef struct ngx_http_lua_socket_tcp_server_s
ngx_http_lua_socket_tcp_server_t;

typedef struct ngx_http_lua_socket_tcp_upstream_s
ngx_http_lua_socket_tcp_upstream_t;

@@ -30,6 +33,10 @@ typedef
int (*ngx_http_lua_socket_tcp_retval_handler)(ngx_http_request_t *r,
ngx_http_lua_socket_tcp_upstream_t *u, lua_State *L);

typedef
int (*ngx_http_lua_socket_tcp_server_retval_handler)(ngx_http_request_t *r,
ngx_http_lua_socket_tcp_server_t *s, lua_State *L);


typedef void (*ngx_http_lua_socket_tcp_upstream_handler_pt)
(ngx_http_request_t *r, ngx_http_lua_socket_tcp_upstream_t *u);
@@ -72,6 +79,21 @@ typedef struct {

} ngx_http_lua_socket_pool_t;

struct ngx_http_lua_socket_tcp_server_s {
ngx_http_lua_socket_tcp_server_retval_handler prepare_retvals;

ngx_str_t host;
int port;
ngx_listening_t *listening;
ngx_http_request_t *request;
ngx_connection_t *connection;
ngx_http_cleanup_pt *cleanup;

ngx_http_lua_co_ctx_t *co_ctx;

unsigned ft_type:16;
unsigned accept_waiting:1;
};

struct ngx_http_lua_socket_tcp_upstream_s {
ngx_http_lua_socket_tcp_retval_handler read_prepare_retvals;
2 changes: 1 addition & 1 deletion t/062-count.t
Original file line number Diff line number Diff line change
@@ -459,7 +459,7 @@ worker: 4
--- request
GET /test
--- response_body
n = 13
n = 15
--- no_error_log
[error]