PERFORCE change 114038 for review

Michael Bushkov bushman at FreeBSD.org
Mon Feb 5 10:25:42 UTC 2007


http://perforce.freebsd.org/chv.cgi?CH=114038

Change 114038 by bushman at bushman_nss_ldap_cached on 2007/02/05 10:24:49

	nss_ldap now works correctly, when the processor forks()

Affected files ...

.. //depot/projects/soc2006/nss_ldap_cached/src/lib/nss_ldap/ldapconn.c#16 edit

Differences ...

==== //depot/projects/soc2006/nss_ldap_cached/src/lib/nss_ldap/ldapconn.c#16 (text+ko) ====

@@ -100,7 +100,11 @@
 {
 	struct nss_ldap_connection_error conn_err;
 	int dummy_fd, backup_fd, rv;
-	
+
+	/* 
+	 * If we can't get the socket from ldap connection, then don't
+	 * close it gracefully and just ignore it.
+	 */	
 	if (conn->sock_fd == -1)
 		return (NSS_LDAP_CONNECTION_ERROR);
 	
@@ -114,7 +118,7 @@
 	if (dummy_fd != conn->sock_fd) {
 		backup_fd = dup(conn->sock_fd);
 		dup2(dummy_fd, conn->sock_fd);	
-		close (conn->sock_fd);
+		close(conn->sock_fd);
 	}
 	memset(&conn_err, 0, sizeof(struct nss_ldap_connection_error));
 	rv = __nss_ldap_disconnect(&__nss_ldap_conf->connection_method, conn, 
@@ -138,13 +142,9 @@
 	struct nss_ldap_connection_error conn_err_;
 	int rv;
 	
-	if (check_connection_socket(conn) != 0) {
+	if (check_connection_socket(conn) != 0 || conn->last_pid != getpid()) {
 		rv = close_lost_connection(conn);
 		return (NSS_LDAP_CONNECTION_ERROR);
-	} else if (conn->last_pid != getpid()) {
-		(void)__nss_ldap_disconnect(&__nss_ldap_conf->connection_method, 
-		conn, __nss_ldap_conf, &conn_err_);
-		return (NSS_LDAP_CONNECTION_ERROR);		
 	} else
 		return (NSS_LDAP_SUCCESS);
 }


More information about the p4-projects mailing list