Skip to content

Commit

Permalink
bugfix: fixed keepalive error in cosocket.
Browse files Browse the repository at this point in the history
Go to openresty/lua-nginx-module#2347 for more details.
  • Loading branch information
zhuizhuhaomeng authored Aug 6, 2024
1 parent f56c53b commit 5954e22
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 5 deletions.
10 changes: 10 additions & 0 deletions src/ngx_stream_lua_socket_tcp.c
Original file line number Diff line number Diff line change
Expand Up @@ -5618,6 +5618,16 @@ ngx_stream_lua_socket_keepalive_close_handler(ngx_event_t *ev)
"check stale events");

n = recv(c->fd, buf, 1, MSG_PEEK);
#if (NGX_STREAM_SSL)
/* ignore ssl protocol data like change cipher spec */
if (n == 1 && c->ssl != NULL) {
n = c->recv(c, (unsigned char *) buf, 1);
if (n == NGX_AGAIN) {
n = -1;
ngx_socket_errno = NGX_EAGAIN;
}
}
#endif /* NGX_STREAM_SSL */

if (n == -1 && ngx_socket_errno == NGX_EAGAIN) {
/* stale event */
Expand Down
10 changes: 5 additions & 5 deletions t/129-ssl-socket.t
Original file line number Diff line number Diff line change
Expand Up @@ -1533,11 +1533,11 @@ set keepalive: 1 nil
--- grep_error_log eval: qr/stream lua ssl (?:set|save|free) session: [0-9A-F]+/
--- grep_error_log_out eval
qr/^stream lua ssl save session: ([0-9A-F]+)
stream lua ssl save session: \1
stream lua ssl save session: \1
stream lua ssl free session: \1
stream lua ssl free session: \1
stream lua ssl free session: \1
stream lua ssl save session: ([0-9A-F]+)
stream lua ssl save session: ([0-9A-F]+)
stream lua ssl free session: ([0-9A-F]+)
stream lua ssl free session: ([0-9A-F]+)
stream lua ssl free session: ([0-9A-F]+)
$/

--- error_log
Expand Down

0 comments on commit 5954e22

Please sign in to comment.