From 2335995140903582672d9191ef014f9a6fc00702 Mon Sep 17 00:00:00 2001 From: Mark Reynolds Date: Mar 06 2012 16:28:59 +0000 Subject: Ticket #191 - Implement SO_KEEPALIVE in network calls Bug Description: Need to set the KeepAlive socket option on DS connections Fix Description: Set PR_SockOpt_Keepalive on DS connections Reviewed by: richm (Thanks Rich!) https://fedorahosted.org/389/ticket/191 ` --- diff --git a/ldap/servers/slapd/daemon.c b/ldap/servers/slapd/daemon.c index 922802c..85daa28 100644 --- a/ldap/servers/slapd/daemon.c +++ b/ldap/servers/slapd/daemon.c @@ -3033,6 +3033,17 @@ int configure_pr_socket( PRFileDesc **pr_socket, int secure, int local ) } #endif /* !_WIN32 */ + /* Set keep_alive to keep old connections from lingering */ + pr_socketoption.option = PR_SockOpt_Keepalive; + pr_socketoption.value.keep_alive = 1; + if ( PR_SetSocketOption( *pr_socket, &pr_socketoption ) == PR_FAILURE ) { + PRErrorCode prerr = PR_GetError(); + LDAPDebug( LDAP_DEBUG_ANY, + "PR_SetSocketOption(PR_SockOpt_Keepalive failed, " + SLAPI_COMPONENT_NAME_NSPR " error %d (%s)\n", + prerr, slapd_pr_strerror(prerr), 0 ); + } + if ( secure ) { pr_socketoption.option = PR_SockOpt_Nonblocking;