Previously, ngx_chain_writer() re-posted the write event to continue
a capped send whenever output data remained and c->write->ready was
still set. This was wrong when c->send_chain() returned without
sending anything while the write event still looked ready, notably
when SSL_write() returned SSL_ERROR_WANT_READ. The event was then
re-posted on every event loop iteration, busy-looping the worker at
100% CPU.
The re-post was introduced without a progress check in
b3b368184
(1.21.4). A check is now added by requiring that c->send_chain()
advanced c->sent.
{
ngx_chain_writer_ctx_t *ctx = data;
- off_t size;
+ off_t size, sent;
ngx_chain_t *cl, *ln, *chain;
ngx_connection_t *c;
return NGX_OK;
}
+ sent = c->sent;
+
chain = c->send_chain(c, ctx->out, ctx->limit);
ngx_log_debug1(NGX_LOG_DEBUG_CORE, c->log, 0,
return NGX_ERROR;
}
- if (chain && c->write->ready) {
+ if (chain && c->write->ready && c->sent != sent) {
ngx_post_event(c->write, &ngx_posted_next_events);
}