Commit 42c5a40b authored by Kurt Zeilenga's avatar Kurt Zeilenga
Browse files

Implement keep alives. Probably should be a configuration option.

parent 4b832f1d
...@@ -211,6 +211,7 @@ set_socket( struct sockaddr_in *addr ) ...@@ -211,6 +211,7 @@ set_socket( struct sockaddr_in *addr )
} }
#endif #endif
#ifdef SO_REUSEADDR
tmp = 1; tmp = 1;
if ( setsockopt( tcps, SOL_SOCKET, SO_REUSEADDR, if ( setsockopt( tcps, SOL_SOCKET, SO_REUSEADDR,
(char *) &tmp, sizeof(tmp) ) == -1 ) (char *) &tmp, sizeof(tmp) ) == -1 )
...@@ -222,6 +223,7 @@ set_socket( struct sockaddr_in *addr ) ...@@ -222,6 +223,7 @@ set_socket( struct sockaddr_in *addr )
err > -1 && err < sys_nerr err > -1 && err < sys_nerr
? sys_errlist[err] : "unknown" ); ? sys_errlist[err] : "unknown" );
} }
#endif
if ( bind( tcps, (struct sockaddr *) addr, sizeof(*addr) ) == -1 ) { if ( bind( tcps, (struct sockaddr *) addr, sizeof(*addr) ) == -1 ) {
int err = errno; int err = errno;
...@@ -280,7 +282,7 @@ slapd_daemon_task( ...@@ -280,7 +282,7 @@ slapd_daemon_task(
while ( !slapd_shutdown ) { while ( !slapd_shutdown ) {
unsigned int i; unsigned int i;
int ns, nfds; int ns, nfds, tmp;
fd_set readfds; fd_set readfds;
fd_set writefds; fd_set writefds;
...@@ -453,6 +455,21 @@ slapd_daemon_task( ...@@ -453,6 +455,21 @@ slapd_daemon_task(
} }
#endif /* HAVE_TCPD */ #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 ) { if( (id = connection_init(s, client_name, client_addr)) < 0 ) {
Debug( LDAP_DEBUG_ANY, Debug( LDAP_DEBUG_ANY,
"daemon: connection_init(%d, %s, %s) failed.\n", "daemon: connection_init(%d, %s, %s) failed.\n",
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment