Skip to content

Commit e5992f7

Browse files
committed
bugfix: we might not respond to client abort events when lua_check_client_abort is on.
1 parent cd3c6bd commit e5992f7

File tree

3 files changed

+27
-0
lines changed

3 files changed

+27
-0
lines changed

src/ngx_http_lua_accessby.c

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -239,6 +239,7 @@ ngx_http_lua_access_by_chunk(lua_State *L, ngx_http_request_t *r)
239239
int co_ref;
240240
ngx_int_t rc;
241241
lua_State *co;
242+
ngx_event_t *rev;
242243
ngx_connection_t *c;
243244
ngx_http_lua_ctx_t *ctx;
244245
ngx_http_cleanup_t *cln;
@@ -308,6 +309,14 @@ ngx_http_lua_access_by_chunk(lua_State *L, ngx_http_request_t *r)
308309
if (llcf->check_client_abort) {
309310
r->read_event_handler = ngx_http_lua_rd_check_broken_connection;
310311

312+
rev = r->connection->read;
313+
314+
if ((ngx_event_flags & NGX_USE_LEVEL_EVENT) && !rev->active) {
315+
if (ngx_add_event(rev, NGX_READ_EVENT, 0) != NGX_OK) {
316+
return NGX_ERROR;
317+
}
318+
}
319+
311320
} else {
312321
r->read_event_handler = ngx_http_block_reading;
313322
}

src/ngx_http_lua_contentby.c

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ ngx_http_lua_content_by_chunk(lua_State *L, ngx_http_request_t *r)
2727
int co_ref;
2828
ngx_int_t rc;
2929
lua_State *co;
30+
ngx_event_t *rev;
3031
ngx_http_lua_ctx_t *ctx;
3132
ngx_http_cleanup_t *cln;
3233

@@ -96,6 +97,14 @@ ngx_http_lua_content_by_chunk(lua_State *L, ngx_http_request_t *r)
9697
if (llcf->check_client_abort) {
9798
r->read_event_handler = ngx_http_lua_rd_check_broken_connection;
9899

100+
rev = r->connection->read;
101+
102+
if ((ngx_event_flags & NGX_USE_LEVEL_EVENT) && !rev->active) {
103+
if (ngx_add_event(rev, NGX_READ_EVENT, 0) != NGX_OK) {
104+
return NGX_ERROR;
105+
}
106+
}
107+
99108
} else {
100109
r->read_event_handler = ngx_http_block_reading;
101110
}

src/ngx_http_lua_rewriteby.c

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -235,6 +235,7 @@ ngx_http_lua_rewrite_by_chunk(lua_State *L, ngx_http_request_t *r)
235235
int co_ref;
236236
lua_State *co;
237237
ngx_int_t rc;
238+
ngx_event_t *rev;
238239
ngx_connection_t *c;
239240
ngx_http_lua_ctx_t *ctx;
240241
ngx_http_cleanup_t *cln;
@@ -303,6 +304,14 @@ ngx_http_lua_rewrite_by_chunk(lua_State *L, ngx_http_request_t *r)
303304
if (llcf->check_client_abort) {
304305
r->read_event_handler = ngx_http_lua_rd_check_broken_connection;
305306

307+
rev = r->connection->read;
308+
309+
if ((ngx_event_flags & NGX_USE_LEVEL_EVENT) && !rev->active) {
310+
if (ngx_add_event(rev, NGX_READ_EVENT, 0) != NGX_OK) {
311+
return NGX_ERROR;
312+
}
313+
}
314+
306315
} else {
307316
r->read_event_handler = ngx_http_block_reading;
308317
}

0 commit comments

Comments
 (0)