]> git.kaiwu.me - nginx.git/commitdiff
Upstream: flush low-level buffers on write retry.
authorPatryk Lesiewicz <patryk@google.com>
Fri, 1 Dec 2017 23:59:14 +0000 (15:59 -0800)
committerPatryk Lesiewicz <patryk@google.com>
Fri, 1 Dec 2017 23:59:14 +0000 (15:59 -0800)
If the data to write is bigger than what the socket can send, and the
reminder is smaller than NGX_SSL_BUFSIZE, then SSL_write() fails with
SSL_ERROR_WANT_WRITE. The reminder of payload however is successfully
copied to the low-level buffer and all the output chain buffers are
flushed. This means that retry logic doesn't work because
ngx_http_upstream_process_non_buffered_request() checks only if there's
anything in the output chain buffers and ignores the fact that something
may be buffered in low-level parts of the stack.

Signed-off-by: Patryk Lesiewicz <patryk@google.com>
src/http/ngx_http_upstream.c

index 75f463ba79956d2f01a7858c9fc24bf722ab1b56..6d0f4ee521ce8ee721c390a550f6e1f1bec1310d 100644 (file)
@@ -3533,7 +3533,7 @@ ngx_http_upstream_process_non_buffered_request(ngx_http_request_t *r,
 
         if (do_write) {
 
-            if (u->out_bufs || u->busy_bufs) {
+            if (u->out_bufs || u->busy_bufs || downstream->buffered) {
                 rc = ngx_http_output_filter(r, u->out_bufs);
 
                 if (rc == NGX_ERROR) {