Skip to content

Commit

Permalink
Upstream: fixed timeouts with gRPC, SSL and select (ticket #2229).
Browse files Browse the repository at this point in the history
With SSL it is possible that an established connection is ready for
reading after the handshake.  Further, events might be already disabled
in case of level-triggered event methods.  If this happens and
ngx_http_upstream_send_request() blocks waiting for some data from
the upstream, such as flow control in case of gRPC, the connection
will time out due to no read events on the upstream connection.

Fix is to explicitly check the c->read->ready flag if sending request
blocks and post a read event if it is set.

Note that while it is possible to modify ngx_ssl_handshake() to keep
read events active, this won't completely resolve the issue, since
there can be data already received during the SSL handshake
(see 573bd30e46b4).
  • Loading branch information
mdounin committed Aug 20, 2021
1 parent d4dad02 commit c231640
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions src/http/ngx_http_upstream.c
Original file line number Diff line number Diff line change
Expand Up @@ -2113,6 +2113,10 @@ ngx_http_upstream_send_request(ngx_http_request_t *r, ngx_http_upstream_t *u,
c->tcp_nopush = NGX_TCP_NOPUSH_UNSET;
}

if (c->read->ready) {
ngx_post_event(c->read, &ngx_posted_events);
}

return;
}

Expand Down

0 comments on commit c231640

Please sign in to comment.