ソースを参照

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
`
Mark Reynolds 13 年 前
コミット
2335995140
1 ファイル変更11 行追加0 行削除
  1. 11 0
      ldap/servers/slapd/daemon.c

+ 11 - 0
ldap/servers/slapd/daemon.c

@@ -3033,6 +3033,17 @@ int configure_pr_socket( PRFileDesc **pr_socket, int secure, int local )
 	}
 	}
 #endif /* !_WIN32 */
 #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 ) {
 	if ( secure ) {
 	  
 	  
 		pr_socketoption.option = PR_SockOpt_Nonblocking;
 		pr_socketoption.option = PR_SockOpt_Nonblocking;