Skip to content
Merged
Show file tree
Hide file tree
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
2 changes: 1 addition & 1 deletion src/ngx_http_lua_output.c
Original file line number Diff line number Diff line change
Expand Up @@ -548,7 +548,7 @@ ngx_http_lua_ngx_flush(lua_State *L)
}
#endif

cl = ngx_http_lua_get_flush_chain(r, ctx);
cl = ngx_http_lua_get_flush_chain(r);
if (cl == NULL) {
return luaL_error(L, "no memory");
}
Expand Down
2 changes: 1 addition & 1 deletion src/ngx_http_lua_util.c
Original file line number Diff line number Diff line change
Expand Up @@ -1917,7 +1917,7 @@ ngx_http_lua_flush_pending_output(ngx_http_request_t *r,
rc = ngx_http_lua_output_filter(r, NULL);

} else {
cl = ngx_http_lua_get_flush_chain(r, ctx);
cl = ngx_http_lua_get_flush_chain(r);
if (cl == NULL) {
return NGX_ERROR;
}
Expand Down
18 changes: 15 additions & 3 deletions src/ngx_http_lua_util.h
Original file line number Diff line number Diff line change
Expand Up @@ -487,16 +487,28 @@ ngx_http_lua_cleanup_pending_operation(ngx_http_lua_co_ctx_t *coctx)


static ngx_inline ngx_chain_t *
ngx_http_lua_get_flush_chain(ngx_http_request_t *r, ngx_http_lua_ctx_t *ctx)
ngx_http_lua_get_flush_chain(ngx_http_request_t *r)
{
ngx_chain_t *cl;

cl = ngx_http_lua_chain_get_free_buf(r->connection->log, r->pool,
&ctx->free_bufs, 0);
/*
* The flush buf is deliberately NOT taken from ctx->free_bufs and
* deliberately carries no tag. It is size 0 and ngx_buf_special(), so the
* write filter keeps it queued. If tagged, ngx_chain_update_chains() would
* return it to ctx->free_bufs, and reusing it from there memzeros the
* flush flag away, resulting in "zero size buf in writer t:1 r:0 f:0".
*/
cl = ngx_alloc_chain_link(r->pool);
if (cl == NULL) {
return NULL;
}

cl->buf = ngx_calloc_buf(r->pool);
if (cl->buf == NULL) {
return NULL;
}

cl->next = NULL;
cl->buf->flush = 1;

return cl;
Expand Down
3 changes: 1 addition & 2 deletions t/056-flush.t
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,7 @@ hello, world
hiya
--- no_error_log
[error]
--- error_log
lua reuse free buf chain, but reallocate memory because 5 >= 0
[alert]
--- skip_eval: 4:defined($ENV{MOCKEAGAIN}) && ($ENV{MOCKEAGAIN} =~ /w/)


Expand Down
Loading