[nginx] Core: the ngx_set_connection_log() macro.

Vladimir Homutov vl at nginx.com
Sun Apr 26 07:28:49 UTC 2015


details:   http://hg.nginx.org/nginx/rev/187aa751ad62
branches:  
changeset: 6129:187aa751ad62
user:      Vladimir Homutov <vl at nginx.com>
date:      Sat Apr 25 22:44:02 2015 +0300
description:
Core: the ngx_set_connection_log() macro.

The http and stream versions of this macro were identical.

diffstat:

 src/core/ngx_connection.h       |  11 +++++++++++
 src/http/ngx_http_core_module.c |   2 +-
 src/http/ngx_http_request.c     |   6 +++---
 src/http/ngx_http_request.h     |  11 -----------
 src/stream/ngx_stream.c         |   2 +-
 src/stream/ngx_stream.h         |  10 ----------
 src/stream/ngx_stream_handler.c |   2 +-
 7 files changed, 17 insertions(+), 27 deletions(-)

diffs (129 lines):

diff -r 69ad3e77922b -r 187aa751ad62 src/core/ngx_connection.h
--- a/src/core/ngx_connection.h	Fri Apr 24 10:54:06 2015 +0300
+++ b/src/core/ngx_connection.h	Sat Apr 25 22:44:02 2015 +0300
@@ -190,6 +190,17 @@ struct ngx_connection_s {
 };
 
 
+#define ngx_set_connection_log(c, l)                                         \
+                                                                             \
+    c->log->file = l->file;                                                  \
+    c->log->next = l->next;                                                  \
+    c->log->writer = l->writer;                                              \
+    c->log->wdata = l->wdata;                                                \
+    if (!(c->log->log_level & NGX_LOG_DEBUG_CONNECTION)) {                   \
+        c->log->log_level = l->log_level;                                    \
+    }
+
+
 ngx_listening_t *ngx_create_listening(ngx_conf_t *cf, void *sockaddr,
     socklen_t socklen);
 ngx_int_t ngx_set_inherited_sockets(ngx_cycle_t *cycle);
diff -r 69ad3e77922b -r 187aa751ad62 src/http/ngx_http_core_module.c
--- a/src/http/ngx_http_core_module.c	Fri Apr 24 10:54:06 2015 +0300
+++ b/src/http/ngx_http_core_module.c	Sat Apr 25 22:44:02 2015 +0300
@@ -1445,7 +1445,7 @@ ngx_http_update_location_config(ngx_http
     }
 
     if (r == r->main) {
-        ngx_http_set_connection_log(r->connection, clcf->error_log);
+        ngx_set_connection_log(r->connection, clcf->error_log);
     }
 
     if ((ngx_io.flags & NGX_IO_SENDFILE) && clcf->sendfile) {
diff -r 69ad3e77922b -r 187aa751ad62 src/http/ngx_http_request.c
--- a/src/http/ngx_http_request.c	Fri Apr 24 10:54:06 2015 +0300
+++ b/src/http/ngx_http_request.c	Sat Apr 25 22:44:02 2015 +0300
@@ -543,7 +543,7 @@ ngx_http_create_request(ngx_connection_t
 
     clcf = ngx_http_get_module_loc_conf(r, ngx_http_core_module);
 
-    ngx_http_set_connection_log(r->connection, clcf->error_log);
+    ngx_set_connection_log(r->connection, clcf->error_log);
 
     r->header_in = hc->nbusy ? hc->busy[0] : c->buffer;
 
@@ -867,7 +867,7 @@ ngx_http_ssl_servername(ngx_ssl_conn_t *
 
     clcf = ngx_http_get_module_loc_conf(hc->conf_ctx, ngx_http_core_module);
 
-    ngx_http_set_connection_log(c, clcf->error_log);
+    ngx_set_connection_log(c, clcf->error_log);
 
     sscf = ngx_http_get_module_srv_conf(hc->conf_ctx, ngx_http_ssl_module);
 
@@ -2073,7 +2073,7 @@ ngx_http_set_virtual_server(ngx_http_req
 
     clcf = ngx_http_get_module_loc_conf(r, ngx_http_core_module);
 
-    ngx_http_set_connection_log(r->connection, clcf->error_log);
+    ngx_set_connection_log(r->connection, clcf->error_log);
 
     return NGX_OK;
 }
diff -r 69ad3e77922b -r 187aa751ad62 src/http/ngx_http_request.h
--- a/src/http/ngx_http_request.h	Fri Apr 24 10:54:06 2015 +0300
+++ b/src/http/ngx_http_request.h	Sat Apr 25 22:44:02 2015 +0300
@@ -586,17 +586,6 @@ extern ngx_http_header_t       ngx_http_
 extern ngx_http_header_out_t   ngx_http_headers_out[];
 
 
-#define ngx_http_set_connection_log(c, l)                                     \
-                                                                              \
-    c->log->file = l->file;                                                   \
-    c->log->next = l->next;                                                   \
-    c->log->writer = l->writer;                                               \
-    c->log->wdata = l->wdata;                                                 \
-    if (!(c->log->log_level & NGX_LOG_DEBUG_CONNECTION)) {                    \
-        c->log->log_level = l->log_level;                                     \
-    }
-
-
 #define ngx_http_set_log_request(log, r)                                      \
     ((ngx_http_log_ctx_t *) log->data)->current_request = r
 
diff -r 69ad3e77922b -r 187aa751ad62 src/stream/ngx_stream.c
--- a/src/stream/ngx_stream.c	Fri Apr 24 10:54:06 2015 +0300
+++ b/src/stream/ngx_stream.c	Sat Apr 25 22:44:02 2015 +0300
@@ -370,8 +370,8 @@ ngx_stream_optimize_servers(ngx_conf_t *
             ls->pool_size = 256;
 
             cscf = addr->ctx->srv_conf[ngx_stream_core_module.ctx_index];
+
             ls->logp = cscf->error_log;
-
             ls->log.data = &ls->addr_text;
             ls->log.handler = ngx_accept_log_error;
 
diff -r 69ad3e77922b -r 187aa751ad62 src/stream/ngx_stream.h
--- a/src/stream/ngx_stream.h	Fri Apr 24 10:54:06 2015 +0300
+++ b/src/stream/ngx_stream.h	Sat Apr 25 22:44:02 2015 +0300
@@ -192,16 +192,6 @@ typedef struct {
             ->main_conf[module.ctx_index]:                                     \
         NULL)
 
-#define ngx_stream_set_connection_log(c, l)                                    \
-                                                                               \
-    c->log->file = l->file;                                                    \
-    c->log->next = l->next;                                                    \
-    c->log->writer = l->writer;                                                \
-    c->log->wdata = l->wdata;                                                  \
-    if (!(c->log->log_level & NGX_LOG_DEBUG_CONNECTION)) {                     \
-        c->log->log_level = l->log_level;                                      \
-    }
-
 
 void ngx_stream_init_connection(ngx_connection_t *c);
 void ngx_stream_close_connection(ngx_connection_t *c);
diff -r 69ad3e77922b -r 187aa751ad62 src/stream/ngx_stream_handler.c
--- a/src/stream/ngx_stream_handler.c	Fri Apr 24 10:54:06 2015 +0300
+++ b/src/stream/ngx_stream_handler.c	Sat Apr 25 22:44:02 2015 +0300
@@ -130,7 +130,7 @@ ngx_stream_init_connection(ngx_connectio
 
     cscf = ngx_stream_get_module_srv_conf(s, ngx_stream_core_module);
 
-    ngx_stream_set_connection_log(c, cscf->error_log);
+    ngx_set_connection_log(c, cscf->error_log);
 
     len = ngx_sock_ntop(c->sockaddr, c->socklen, text, NGX_SOCKADDR_STRLEN, 1);
 



More information about the nginx-devel mailing list