You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@trafficserver.apache.org by ok...@apache.org on 2017/11/09 15:55:14 UTC

[trafficserver] branch master updated: Correct the listen_backlog

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

oknet pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/trafficserver.git


The following commit(s) were added to refs/heads/master by this push:
     new 0724e34  Correct the listen_backlog
0724e34 is described below

commit 0724e342cd04efb470034d91347f4ea4123c8e21
Author: Oknet Xu <xu...@skyguard.com.cn>
AuthorDate: Thu Nov 9 17:27:39 2017 +0800

    Correct the listen_backlog
---
 iocore/net/Connection.cc |  2 +-
 lib/ts/ink_inet.cc       | 12 ++++++------
 2 files changed, 7 insertions(+), 7 deletions(-)

diff --git a/iocore/net/Connection.cc b/iocore/net/Connection.cc
index d5635d2..e594763 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 0fa4251..8a96985 100644
--- a/lib/ts/ink_inet.cc
+++ b/lib/ts/ink_inet.cc
@@ -571,19 +571,19 @@ ats_tcp_somaxconn()
 /* 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
-
-  std::ifstream f("/proc/sys/net/ipv4/tcp_max_syn_backlog", std::ifstream::in);
+#else
+  std::ifstream f("/proc/sys/net/core/somaxconn", std::ifstream::in);
   if (f.good()) {
     f >> value;
   }
+#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) {
+  if (value <= 0 || value > 65535) {
     value = 1024;
   }
 

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