]> git.kaiwu.me - nginx.git/commitdiff
On DragonFlyBSD, TCP_KEEPIDLE and TCP_KEEPINTVL are in msecs.
authorRuslan Ermilov <ru@nginx.com>
Thu, 25 Jul 2013 08:46:03 +0000 (12:46 +0400)
committerRuslan Ermilov <ru@nginx.com>
Thu, 25 Jul 2013 08:46:03 +0000 (12:46 +0400)
Based on a patch by Sepherosa Ziehau.

src/core/ngx_connection.c
src/os/unix/ngx_freebsd_config.h

index 0ef145b523d728aff1671800bbfa3379c9184e4a..e12d3efc0ebc289175b9009d03e3dfe8e911232c 100644 (file)
@@ -515,24 +515,36 @@ ngx_configure_listening_sockets(ngx_cycle_t *cycle)
 #if (NGX_HAVE_KEEPALIVE_TUNABLE)
 
         if (ls[i].keepidle) {
+            value = ls[i].keepidle;
+
+#if (NGX_KEEPALIVE_FACTOR)
+            value *= NGX_KEEPALIVE_FACTOR;
+#endif
+
             if (setsockopt(ls[i].fd, IPPROTO_TCP, TCP_KEEPIDLE,
-                           (const void *) &ls[i].keepidle, sizeof(int))
+                           (const void *) &value, sizeof(int))
                 == -1)
             {
                 ngx_log_error(NGX_LOG_ALERT, cycle->log, ngx_socket_errno,
                               "setsockopt(TCP_KEEPIDLE, %d) %V failed, ignored",
-                              ls[i].keepidle, &ls[i].addr_text);
+                              value, &ls[i].addr_text);
             }
         }
 
         if (ls[i].keepintvl) {
+            value = ls[i].keepintvl;
+
+#if (NGX_KEEPALIVE_FACTOR)
+            value *= NGX_KEEPALIVE_FACTOR;
+#endif
+
             if (setsockopt(ls[i].fd, IPPROTO_TCP, TCP_KEEPINTVL,
-                           (const void *) &ls[i].keepintvl, sizeof(int))
+                           (const void *) &value, sizeof(int))
                 == -1)
             {
                 ngx_log_error(NGX_LOG_ALERT, cycle->log, ngx_socket_errno,
                              "setsockopt(TCP_KEEPINTVL, %d) %V failed, ignored",
-                             ls[i].keepintvl, &ls[i].addr_text);
+                             value, &ls[i].addr_text);
             }
         }
 
index 5b3ff278c01906e114e4a51e7ad78979a3f2c0b4..248e7a731012bdf3e901f1626e392a00a8a354f7 100644 (file)
@@ -94,6 +94,11 @@ typedef struct aiocb  ngx_aiocb_t;
 #define NGX_LISTEN_BACKLOG        -1
 
 
+#ifdef __DragonFly__
+#define NGX_KEEPALIVE_FACTOR      1000
+#endif
+
+
 #if (__FreeBSD_version < 430000 || __FreeBSD_version < 500012)
 
 pid_t rfork_thread(int flags, void *stack, int (*func)(void *arg), void *arg);