You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@trafficserver.apache.org by zw...@apache.org on 2017/11/13 22:06:48 UTC

[trafficserver] branch 7.1.x updated: Correct the listen_backlog

This is an automated email from the ASF dual-hosted git repository.

zwoop pushed a commit to branch 7.1.x
in repository https://gitbox.apache.org/repos/asf/trafficserver.git


The following commit(s) were added to refs/heads/7.1.x by this push:
     new 5cabccc  Correct the listen_backlog
5cabccc is described below

commit 5cabccc1e1595055277898531896529af5806064
Author: Oknet Xu <xu...@skyguard.com.cn>
AuthorDate: Mon Nov 13 17:07:36 2017 +0800

    Correct the listen_backlog
    
    (cherry picked from commit 0724e342cd04efb470034d91347f4ea4123c8e21)
---
 iocore/net/Connection.cc |  2 +-
 lib/ts/ink_inet.cc       | 16 ++++++++--------
 2 files changed, 9 insertions(+), 9 deletions(-)

diff --git a/iocore/net/Connection.cc b/iocore/net/Connection.cc
index e52af10..78f5a6a 100644
--- a/iocore/net/Connection.cc
+++ b/iocore/net/Connection.cc
@@ -45,7 +45,7 @@ get_listen_backlog()
   int listen_backlog;
 
   REC_ReadConfigInteger(listen_backlog, "proxy.config.net.listen_backlog");
-  return listen_backlog >= 0 ? listen_backlog : ats_tcp_somaxconn();
+  return (0 < listen_backlog && listen_backlog <= 65535) ? listen_backlog : ats_tcp_somaxconn();
 }
 
 //
diff --git a/lib/ts/ink_inet.cc b/lib/ts/ink_inet.cc
index 01c2127..10d9b28 100644
--- a/lib/ts/ink_inet.cc
+++ b/lib/ts/ink_inet.cc
@@ -675,18 +675,17 @@ REGRESSION_TEST(Ink_Inet)(RegressionTest *t, int /* atype */, int *pstatus)
 int
 ats_tcp_somaxconn()
 {
-  int fd;
   int value = 0;
 
 /* Darwin version ... */
 #if HAVE_SYSCTLBYNAME
   size_t value_size = sizeof(value);
-  if (sysctlbyname("kern.ipc.somaxconn", &value, &value_size, nullptr, 0) == 0) {
-    return value;
+  if (sysctlbyname("kern.ipc.somaxconn", &value, &value_size, nullptr, 0) < 0) {
+    value = 0;
   }
-#endif
-
-  fd = open("/proc/sys/net/ipv4/tcp_max_syn_backlog", O_RDONLY);
+#else
+  int fd;
+  fd = open("/proc/sys/net/core/somaxconn", O_RDONLY);
   if (fd != -1) {
     textBuffer text(0);
     text.slurp(fd);
@@ -695,11 +694,12 @@ ats_tcp_somaxconn()
     }
     close(fd);
   }
+#endif
 
   // Default to the compatible value we used before detection. SOMAXCONN is the right
   // macro to use, but most systems set this to 128, which is just too small.
-  if (value <= 0) {
-    return 1024;
+  if (value <= 0 || value > 65535) {
+    value = 1024;
   }
 
   return value;

-- 
To stop receiving notification emails like this one, please contact
['"commits@trafficserver.apache.org" <co...@trafficserver.apache.org>'].