Welcome! Log In Create A New Profile

Advanced

[PATCH] Fix logging keepalive related variables bug

Joshua Zhu
February 13, 2012 02:10AM
Hi,

A bug was introduced in revision 3181 that r->keepalive was set to 0
before calling ngx_http_log_reques(), so the $sent_http_connection and
$sent_http_keep_alive variables will not work anymore.

The following patch is trying to fix this problem.

diff -uprN nginx-1.1.14/src/http/ngx_http_request.c
nginx-1.1.14-patched/src/http/ngx_http_request.c
--- nginx-1.1.14/src/http/ngx_http_request.c    2012-01-18
23:07:43.000000000 +0800
+++ nginx-1.1.14-patched/src/http/ngx_http_request.c    2012-02-13
12:44:11.190366479 +0800
@@ -2498,8 +2498,6 @@ ngx_http_set_keepalive(ngx_http_request_
         }
     }

-    r->keepalive = 0;
-
     ngx_http_free_request(r, 0);

     c->data = hc;
@@ -2978,6 +2976,7 @@ ngx_http_close_request(ngx_http_request_
 static void
 ngx_http_free_request(ngx_http_request_t *r, ngx_int_t rc)
 {
+    unsigned                   keepalive;
     ngx_log_t                 *log;
     struct linger              linger;
     ngx_http_cleanup_t        *cln;
@@ -2993,12 +2992,22 @@ ngx_http_free_request(ngx_http_request_t
         return;
     }

+    /*
+     * clear r->keepalive to disable preventively calling
+     * ngx_http_set_keepalive() while request cleanup
+     */
+
+    keepalive = r->keepalive;
+    r->keepalive = 0;
+
     for (cln = r->cleanup; cln; cln = cln->next) {
         if (cln->handler) {
             cln->handler(cln->data);
         }
     }

+    r->keepalive = keepalive;
+
 #if (NGX_STAT_STUB)

     if (r->stat_reading) {


Regards,

--
Joshua Zhu
Senior Software Engineer
Server Platforms Team at Taobao
_______________________________________________
nginx-devel mailing list
nginx-devel@nginx.org
http://mailman.nginx.org/mailman/listinfo/nginx-devel
Subject Author Views Posted

[PATCH] Fix logging keepalive related variables bug

Joshua Zhu 1824 February 13, 2012 02:10AM

Re: [PATCH] Fix logging keepalive related variables bug

Joshua Zhu 482 February 23, 2012 02:22AM

Re: [PATCH] Fix logging keepalive related variables bug

Maxim Dounin 598 February 23, 2012 11:34PM

Re: [PATCH] Fix logging keepalive related variables bug

agentzh 474 June 20, 2012 10:56PM

Re: [PATCH] Fix logging keepalive related variables bug

Maxim Dounin 547 June 21, 2012 01:10PM



Sorry, you do not have permission to post/reply in this forum.

Online Users

Guests: 292
Record Number of Users: 8 on April 13, 2023
Record Number of Guests: 421 on December 02, 2018
Powered by nginx      Powered by FreeBSD      PHP Powered      Powered by MariaDB      ipv6 ready