[nginx] Core: output client port number when logging accept event.

Ruslan Ermilov ru at nginx.com
Wed May 21 20:18:55 UTC 2014


details:   http://hg.nginx.org/nginx/rev/524741fd50ed
branches:  
changeset: 5704:524741fd50ed
user:      Ruslan Ermilov <ru at nginx.com>
date:      Thu May 22 00:16:09 2014 +0400
description:
Core: output client port number when logging accept event.

diffstat:

 src/event/ngx_event_accept.c |  14 +++++++++++---
 1 files changed, 11 insertions(+), 3 deletions(-)

diffs (37 lines):

diff -r 7deb01451486 -r 524741fd50ed src/event/ngx_event_accept.c
--- a/src/event/ngx_event_accept.c	Wed May 21 21:56:20 2014 +0400
+++ b/src/event/ngx_event_accept.c	Thu May 22 00:16:09 2014 +0400
@@ -288,9 +288,11 @@ ngx_event_accept(ngx_event_t *ev)
 #if (NGX_DEBUG)
         {
 
+        ngx_str_t             addr;
         struct sockaddr_in   *sin;
         ngx_cidr_t           *cidr;
         ngx_uint_t            i;
+        u_char                text[NGX_SOCKADDR_STRLEN];
 #if (NGX_HAVE_INET6)
         struct sockaddr_in6  *sin6;
         ngx_uint_t            n;
@@ -340,12 +342,18 @@ ngx_event_accept(ngx_event_t *ev)
             continue;
         }
 
+        if (log->log_level & NGX_LOG_DEBUG_EVENT) {
+            addr.data = text;
+            addr.len = ngx_sock_ntop(c->sockaddr, c->socklen, text,
+                                     NGX_SOCKADDR_STRLEN, 1);
+
+            ngx_log_debug3(NGX_LOG_DEBUG_EVENT, log, 0,
+                           "*%uA accept: %V fd:%d", c->number, &addr, s);
+        }
+
         }
 #endif
 
-        ngx_log_debug3(NGX_LOG_DEBUG_EVENT, log, 0,
-                       "*%uA accept: %V fd:%d", c->number, &c->addr_text, s);
-
         if (ngx_add_conn && (ngx_event_flags & NGX_USE_EPOLL_EVENT) == 0) {
             if (ngx_add_conn(c) == NGX_ERROR) {
                 ngx_close_accepted_connection(c);



More information about the nginx-devel mailing list