]> git.sur5r.net Git - openldap/commitdiff
setsockopt( SO_KEEPALIVE ) on the listen() socket. Will be
authorKurt Zeilenga <kurt@openldap.org>
Mon, 24 May 1999 22:20:34 +0000 (22:20 +0000)
committerKurt Zeilenga <kurt@openldap.org>
Mon, 24 May 1999 22:20:34 +0000 (22:20 +0000)
inherited on accept().

servers/slapd/daemon.c

index b84ce2d18844735a12eddf2d57438a30995f1c27..86410a54fc53b58572066581d8db576f411aa8e2 100644 (file)
@@ -224,6 +224,20 @@ set_socket( struct sockaddr_in *addr )
                                        ? sys_errlist[err] : "unknown" );
                }
 #endif
+#ifdef SO_KEEPALIVE
+               tmp = 1;
+               if ( setsockopt( tcps, SOL_SOCKET, SO_KEEPALIVE,
+                       (char *) &tmp, sizeof(tmp) ) == -1 )
+               {
+                       int err = errno;
+                       Debug( LDAP_DEBUG_ANY,
+                               "slapd(%d): setsockopt(KEEPALIVE) failed errno %d (%s)\n",
+                       tcps, err,
+                               err > -1 && err < sys_nerr
+                                       ? sys_errlist[err] : "unknown" );
+               }
+#endif
+
 
                if ( bind( tcps, (struct sockaddr *) addr, sizeof(*addr) ) == -1 ) {
                        int err = errno;
@@ -282,7 +296,7 @@ slapd_daemon_task(
 
        while ( !slapd_shutdown ) {
                unsigned int i;
-               int ns, nfds, tmp;
+               int ns, nfds;
 
                fd_set                  readfds;
                fd_set                  writefds;
@@ -456,20 +470,6 @@ slapd_daemon_task(
 #endif /* HAVE_TCPD */
 
 
-#ifdef SO_KEEPALIVE
-                       tmp = 1;
-                       if ( setsockopt( tcps, SOL_SOCKET, SO_KEEPALIVE,
-                               (char *) &tmp, sizeof(tmp) ) == -1 )
-                       {
-                               int err = errno;
-                               Debug( LDAP_DEBUG_ANY,
-                                       "slapd(%d): setsockopt(KEEPALIVE) failed errno %d (%s)\n",
-                               tcps, err,
-                                       err > -1 && err < sys_nerr
-                                               ? sys_errlist[err] : "unknown" );
-                       }
-#endif
-
                        if( (id = connection_init(s, client_name, client_addr)) < 0 ) {
                                Debug( LDAP_DEBUG_ANY,
                                        "daemon: connection_init(%d, %s, %s) failed.\n",