Use a return code for ngx_http_terminate_request()

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

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 D.
http://nginx.org/

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs