Proposal minor patch on ngx_http_upstream.c

Hello,

errno is only set on error, so if |recv()| is a success, |err| will have
a
random value.
Only debug message are impacted.
Can you check if it is ok?
Comments are welcome.
Feel free to change the patch.

Regards,

yves


nginx-1.6.0/src/http/ngx_http_upstream.c | 5 ±—
1 file changed, 1 insertion(+), 4 deletions(-)

diff --git a/nginx-1.6.0/src/http/ngx_http_upstream.c
b/nginx-1.6.0/src/http/ngx
index 040bda1…f60acb3 100644
— a/nginx-1.6.0/src/http/ngx_http_upstream.c
+++ b/nginx-1.6.0/src/http/ngx_http_upstream.c
@@ -1128,7 +1128,7 @@
ngx_http_upstream_check_broken_connection(ngx_http_request_t *r,

 n = recv(c->fd, buf, 1, MSG_PEEK);
  • err = ngx_socket_errno;
  • err = n == 1 ? ngx_socket_errno : 0;

    ngx_log_debug1(NGX_LOG_DEBUG_HTTP, ev->log, err,
    “http upstream recv(): %d”, n);
    @@ -1158,9 +1158,6 @@
    ngx_http_upstream_check_broken_connection(ngx_http_request_t *r,
    }

    ev->error = 1;
    
  • } else { /* n == 0 */

  •    err = 0;
    

    }

    ev->eof = 1;


1.7.10.4

Posted at Nginx Forum:
http://forum.nginx.org/read.php?2,250570,250570#msg-250570

Hello Ruslan,

Thanks for your remark.
Is it necessary to send the correct patch ?

Regards,

yves

Posted at Nginx Forum:
http://forum.nginx.org/read.php?2,250570,250579#msg-250579

Hello,

Here is the corresponding patch.

Regards,

yves

HG changeset patch

User Yves Crespin[email protected]

Date 1407480323 -7200

Node ID a62fffc16af816612a4acf34c7a4781f454fa5d1

Parent 8120c2937062998497546a3ecb38b78bb302fe34

Upstream: ngx_socket_errno can only be used if |recv()| failed

if |recv()| is a success, err will have a random value.
only debug message are impacted.

diff -r 8120c2937062 -r a62fffc16af8 src/http/ngx_http_upstream.c
— a/src/http/ngx_http_upstream.c Thu Aug 07 16:04:07 2014 +0200
+++ b/src/http/ngx_http_upstream.c Fri Aug 08 08:45:23 2014 +0200
@@ -1145,7 +1145,7 @@

 n = recv(c->fd, buf, 1, MSG_PEEK);
  • err = ngx_socket_errno;
  • err = (n == -1) ? ngx_socket_errno : 0;

    ngx_log_debug1(NGX_LOG_DEBUG_HTTP, ev->log, err,
    “http upstream recv(): %d”, n);
    @@ -1175,9 +1175,6 @@
    }

    ev->error = 1;
    
  • } else { /* n == 0 */

  •    err = 0;
    

    }

    ev->eof = 1;

Posted at Nginx Forum:
http://forum.nginx.org/read.php?2,250570,252403#msg-252403

On Mon, Jun 02, 2014 at 09:51:42AM -0400, crespin wrote:

— a/nginx-1.6.0/src/http/ngx_http_upstream.c
+++ b/nginx-1.6.0/src/http/ngx_http_upstream.c
@@ -1128,7 +1128,7 @@
ngx_http_upstream_check_broken_connection(ngx_http_request_t *r,

 n = recv(c->fd, buf, 1, MSG_PEEK);
  • err = ngx_socket_errno;
  • err = n == 1 ? ngx_socket_errno : 0;

(n == -1)

  •    err = 0;
    

nginx mailing list
[email protected]
http://mailman.nginx.org/mailman/listinfo/nginx


Ruslan E.

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