diff options
author | Max Romanov <max.romanov@nginx.com> | 2020-12-29 19:01:24 +0300 |
---|---|---|
committer | Max Romanov <max.romanov@nginx.com> | 2020-12-29 19:01:24 +0300 |
commit | d65a66f9d813294917822554311281c5e1a7126b (patch) | |
tree | fe375efda23817f43a1ec7a30ff2250b58477e89 /src/nxt_unit.c | |
parent | d3d6864bdc64f34924e686ff65da704b29aaaa93 (diff) | |
download | unit-d65a66f9d813294917822554311281c5e1a7126b.tar.gz unit-d65a66f9d813294917822554311281c5e1a7126b.tar.bz2 |
Libunit: processing single port message.
This partially reverts the optimisation introduced in 1d84b9e4b459 to avoid an
unpredictable block in nxt_unit_process_port_msg(). Under high load, this
function may never return control to its caller, and the external event loop
(in Node.js and Python asyncio) won't be able to process other scheduled
events.
To reproduce the issue, two request processing types are needed: 'fast' and
'furious'. The 'fast' one simply returns a small response, while the 'furious'
schedules asynchronous calls to external resources. Thus, if Unit is subjected
to a large amount of 'fast' requests, the 'furious' request processing freezes
until the high load ends.
The issue was found by Wu Jian Ping (@wujjpp) during Node.js stream
implementation discussion and relates to PR #502 on GitHub.
Diffstat (limited to '')
-rw-r--r-- | src/nxt_unit.c | 13 |
1 files changed, 0 insertions, 13 deletions
diff --git a/src/nxt_unit.c b/src/nxt_unit.c index 39e7f076..2fef17c5 100644 --- a/src/nxt_unit.c +++ b/src/nxt_unit.c @@ -5016,7 +5016,6 @@ nxt_unit_process_port_msg_impl(nxt_unit_ctx_t *ctx, nxt_unit_port_t *port) int rc; nxt_unit_impl_t *lib; nxt_unit_read_buf_t *rbuf; - nxt_unit_ctx_impl_t *ctx_impl; rbuf = nxt_unit_read_buf_get(ctx); if (nxt_slow_path(rbuf == NULL)) { @@ -5024,9 +5023,6 @@ nxt_unit_process_port_msg_impl(nxt_unit_ctx_t *ctx, nxt_unit_port_t *port) } lib = nxt_container_of(ctx->unit, nxt_unit_impl_t, unit); - ctx_impl = nxt_container_of(ctx, nxt_unit_ctx_impl_t, ctx); - -retry: if (port == lib->shared_port) { rc = nxt_unit_shared_port_recv(ctx, port, rbuf); @@ -5052,15 +5048,6 @@ retry: nxt_unit_process_ready_req(ctx); - if (ctx_impl->online) { - rbuf = nxt_unit_read_buf_get(ctx); - if (nxt_slow_path(rbuf == NULL)) { - return NXT_UNIT_ERROR; - } - - goto retry; - } - return rc; } |