Skip to content

Commit 51c14a8

Browse files
committed
bugfix: segmentation fault might happen when a stale read event happens after the downstream cosocket object is closed. thanks Dejiang Zhu for the report.
1 parent 2fd469d commit 51c14a8

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

src/ngx_http_lua_socket_tcp.c

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4418,15 +4418,18 @@ ngx_http_lua_req_socket_rev_handler(ngx_http_request_t *r)
44184418

44194419
ctx = ngx_http_get_module_ctx(r, ngx_http_lua_module);
44204420
if (ctx == NULL) {
4421+
r->read_event_handler = ngx_http_block_reading;
44214422
return;
44224423
}
44234424

44244425
u = ctx->downstream;
4425-
if (u) {
4426-
u->read_event_handler(r, u);
4426+
if (u == NULL || u->peer.connection == NULL) {
4427+
r->read_event_handler = ngx_http_block_reading;
4428+
return;
44274429
}
4428-
}
44294430

4431+
u->read_event_handler(r, u);
4432+
}
44304433

44314434
static int
44324435
ngx_http_lua_socket_tcp_getreusedtimes(lua_State *L)

0 commit comments

Comments
 (0)