From 42c5a40b78d251ffe4ca9713a638849bf97a689a Mon Sep 17 00:00:00 2001 From: Kurt Zeilenga Date: Mon, 24 May 1999 21:57:26 +0000 Subject: [PATCH] Implement keep alives. Probably should be a configuration option. --- servers/slapd/daemon.c | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/servers/slapd/daemon.c b/servers/slapd/daemon.c index 32485beb26..b84ce2d188 100644 --- a/servers/slapd/daemon.c +++ b/servers/slapd/daemon.c @@ -211,6 +211,7 @@ set_socket( struct sockaddr_in *addr ) } #endif +#ifdef SO_REUSEADDR tmp = 1; if ( setsockopt( tcps, SOL_SOCKET, SO_REUSEADDR, (char *) &tmp, sizeof(tmp) ) == -1 ) @@ -222,6 +223,7 @@ set_socket( struct sockaddr_in *addr ) err > -1 && err < sys_nerr ? sys_errlist[err] : "unknown" ); } +#endif if ( bind( tcps, (struct sockaddr *) addr, sizeof(*addr) ) == -1 ) { int err = errno; @@ -280,7 +282,7 @@ slapd_daemon_task( while ( !slapd_shutdown ) { unsigned int i; - int ns, nfds; + int ns, nfds, tmp; fd_set readfds; fd_set writefds; @@ -453,6 +455,21 @@ 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", -- 2.39.5