]> git.kaiwu.me - nginx.git/commitdiff
Request body: properly handle events while discarding body.
authorMaxim Dounin <mdounin@mdounin.ru>
Wed, 21 Nov 2012 00:57:56 +0000 (00:57 +0000)
committerMaxim Dounin <mdounin@mdounin.ru>
Wed, 21 Nov 2012 00:57:56 +0000 (00:57 +0000)
An attempt to call ngx_handle_read_event() before actually reading
data from a socket might result in read event being disabled, which is
wrong.  Catched by body.t test on Solaris.

src/http/ngx_http_request_body.c

index 691f10e848dcff1a09103a00c5f75c4bcb37a0e5..3c69d052c7a028e0e57fcfbe7621daa53f4a54eb 100644 (file)
@@ -482,19 +482,21 @@ ngx_http_discard_request_body(ngx_http_request_t *r)
         }
     }
 
+    if (ngx_http_read_discarded_request_body(r) == NGX_OK) {
+        r->lingering_close = 0;
+        return NGX_OK;
+    }
+
+    /* == NGX_AGAIN */
+
     r->read_event_handler = ngx_http_discarded_request_body_handler;
 
     if (ngx_handle_read_event(rev, 0) != NGX_OK) {
         return NGX_HTTP_INTERNAL_SERVER_ERROR;
     }
 
-    if (ngx_http_read_discarded_request_body(r) == NGX_OK) {
-        r->lingering_close = 0;
-
-    } else {
-        r->count++;
-        r->discard_body = 1;
-    }
+    r->count++;
+    r->discard_body = 1;
 
     return NGX_OK;
 }