Forum: NGINX use a return code for ngx_http_terminate_request()

2974d09ac2541e892966b762aad84943?d=identicon&s=25 crespin (Guest)
on 2014-06-27 15:07
(Received via mailing list)
Hello,

Reading ngx_http_request.c source code, I notice some call to
ngx_http_terminate_request() is called sometimes with 0 instead of a
return
code.

0 is a correct valid for a return code ... it's NGX_OK.

Is the patch valid ?

It's based on nginx-1.7.2 version.

Thanks for your reply.

yves

Subject: [PATCH] use a return code for ngx_http_terminate_request()

---
 1.0/source/nginx-1.7.2/src/http/ngx_http_request.c |    6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/1.0/source/nginx-1.7.2/src/http/ngx_http_request.c
b/1.0/source/nginx-1.7.2/src/http/ngx_http_request.c
index 4bf9d1f..8ddfc60 100644
--- a/1.0/source/nginx-1.7.2/src/http/ngx_http_request.c
+++ b/1.0/source/nginx-1.7.2/src/http/ngx_http_request.c
@@ -2329,7 +2329,7 @@ ngx_http_finalize_request(ngx_http_request_t *r,
ngx_int_t rc)
         if (r->buffered || r->postponed) {

             if (ngx_http_set_write_handler(r) != NGX_OK) {
-                ngx_http_terminate_request(r, 0);
+                ngx_http_terminate_request(r, NGX_ERROR);
             }

             return;
@@ -2381,7 +2381,7 @@ ngx_http_finalize_request(ngx_http_request_t *r,
ngx_int_t rc)

         if (ngx_http_post_request(pr, NULL) != NGX_OK) {
             r->main->count++;
-            ngx_http_terminate_request(r, 0);
+            ngx_http_terminate_request(r, NGX_ERROR);
             return;
         }

@@ -2395,7 +2395,7 @@ ngx_http_finalize_request(ngx_http_request_t *r,
ngx_int_t rc)
     if (r->buffered || c->buffered || r->postponed || r->blocked) {

         if (ngx_http_set_write_handler(r) != NGX_OK) {
-            ngx_http_terminate_request(r, 0);
+            ngx_http_terminate_request(r, NGX_ERROR);
         }

         return;
--
1.7.10.4

Posted at Nginx Forum:
http://forum.nginx.org/read.php?2,251227,251227#msg-251227
A8108a0961c6087c43cda32c8616dcba?d=identicon&s=25 Maxim Dounin (Guest)
on 2014-06-27 21:39
(Received via mailing list)
Hello!

On Fri, Jun 27, 2014 at 09:07:27AM -0400, crespin wrote:

> Hello,
>
> Reading ngx_http_request.c source code, I notice some call to
> ngx_http_terminate_request() is called sometimes with 0 instead of a return
> code.
>
> 0 is a correct valid for a return code ... it's NGX_OK.
>
> Is the patch valid ?

The ngx_http_terminate_request() function uses "rc" only when it's
positive, and "0" doesn't really mean anything except "we don't
have error code".

--
Maxim Dounin
http://nginx.org/
Please log in before posting. Registration is free and takes only a minute.
Existing account

NEW: Do you have a Google/GoogleMail, Yahoo or Facebook account? No registration required!
Log in with Google account | Log in with Yahoo account | Log in with Facebook account
No account? Register here.