[nginx] Stream: listen backlog=.

Ruslan Ermilov ru at nginx.com
Mon Jun 8 20:30:07 UTC 2015


details:   http://hg.nginx.org/nginx/rev/3e8cddcff381
branches:  
changeset: 6172:3e8cddcff381
user:      Ruslan Ermilov <ru at nginx.com>
date:      Mon Jun 08 23:13:33 2015 +0300
description:
Stream: listen backlog=.

diffstat:

 src/stream/ngx_stream.c             |   2 ++
 src/stream/ngx_stream.h             |   1 +
 src/stream/ngx_stream_core_module.c |  14 ++++++++++++++
 3 files changed, 17 insertions(+), 0 deletions(-)

diffs (54 lines):

diff -r f61049c80458 -r 3e8cddcff381 src/stream/ngx_stream.c
--- a/src/stream/ngx_stream.c	Mon Jun 08 23:11:58 2015 +0300
+++ b/src/stream/ngx_stream.c	Mon Jun 08 23:13:33 2015 +0300
@@ -360,6 +360,8 @@ ngx_stream_optimize_servers(ngx_conf_t *
             ls->log.data = &ls->addr_text;
             ls->log.handler = ngx_accept_log_error;
 
+            ls->backlog = addr[i].opt.backlog;
+
             ls->keepalive = addr[i].opt.so_keepalive;
 #if (NGX_HAVE_KEEPALIVE_TUNABLE)
             ls->keepidle = addr[i].opt.tcp_keepidle;
diff -r f61049c80458 -r 3e8cddcff381 src/stream/ngx_stream.h
--- a/src/stream/ngx_stream.h	Mon Jun 08 23:11:58 2015 +0300
+++ b/src/stream/ngx_stream.h	Mon Jun 08 23:13:33 2015 +0300
@@ -65,6 +65,7 @@ typedef struct {
     int                     tcp_keepintvl;
     int                     tcp_keepcnt;
 #endif
+    int                     backlog;
 } ngx_stream_listen_t;
 
 
diff -r f61049c80458 -r 3e8cddcff381 src/stream/ngx_stream_core_module.c
--- a/src/stream/ngx_stream_core_module.c	Mon Jun 08 23:11:58 2015 +0300
+++ b/src/stream/ngx_stream_core_module.c	Mon Jun 08 23:13:33 2015 +0300
@@ -330,6 +330,7 @@ ngx_stream_core_listen(ngx_conf_t *cf, n
     ngx_memcpy(&ls->u.sockaddr, u.sockaddr, u.socklen);
 
     ls->socklen = u.socklen;
+    ls->backlog = NGX_LISTEN_BACKLOG;
     ls->wildcard = u.wildcard;
     ls->ctx = cf->ctx;
 
@@ -344,6 +345,19 @@ ngx_stream_core_listen(ngx_conf_t *cf, n
             continue;
         }
 
+        if (ngx_strncmp(value[i].data, "backlog=", 8) == 0) {
+            ls->backlog = ngx_atoi(value[i].data + 8, value[i].len - 8);
+            ls->bind = 1;
+
+            if (ls->backlog == NGX_ERROR || ls->backlog == 0) {
+                ngx_conf_log_error(NGX_LOG_EMERG, cf, 0,
+                                   "invalid backlog \"%V\"", &value[i]);
+                return NGX_CONF_ERROR;
+            }
+
+            continue;
+        }
+
         if (ngx_strncmp(value[i].data, "ipv6only=o", 10) == 0) {
 #if (NGX_HAVE_INET6 && defined IPV6_V6ONLY)
             struct sockaddr  *sa;



More information about the nginx-devel mailing list