]> git.sur5r.net Git - openldap/commitdiff
ITS#4541 refine commit for #4524
authorHoward Chu <hyc@openldap.org>
Fri, 12 May 2006 06:16:32 +0000 (06:16 +0000)
committerHoward Chu <hyc@openldap.org>
Fri, 12 May 2006 06:16:32 +0000 (06:16 +0000)
libraries/libldap/open.c

index e01c5ea28e4781d2dcb97b4731e9789a105852b3..d02048dfd688288d4a06456c5068c00be8cdde7b 100644 (file)
 
 int ldap_open_defconn( LDAP *ld )
 {
+       int rc = 0;
+
 #ifdef LDAP_R_COMPILE
        ldap_pvt_thread_mutex_lock( &ld->ld_req_mutex );
 #endif /* LDAP_R_COMPILE */
-       ld->ld_defconn = ldap_new_connection( ld,
-               &ld->ld_options.ldo_defludp, 1, 1, NULL );
+       if ( ld->ld_defconn == NULL ) {
+               ld->ld_defconn = ldap_new_connection( ld,
+                       &ld->ld_options.ldo_defludp, 1, 1, NULL );
+
+               if( ld->ld_defconn == NULL ) {
+                       ld->ld_errno = LDAP_SERVER_DOWN;
+                       rc = -1;
+               } else {
+                       ++ld->ld_defconn->lconn_refcnt; /* so it never gets closed/freed */
+               }
+       }
 #ifdef LDAP_R_COMPILE
        ldap_pvt_thread_mutex_unlock( &ld->ld_req_mutex );
 #endif /* LDAP_R_COMPILE */
-
-       if( ld->ld_defconn == NULL ) {
-               ld->ld_errno = LDAP_SERVER_DOWN;
-               return -1;
-       }
-
-       ++ld->ld_defconn->lconn_refcnt; /* so it never gets closed/freed */
-       return 0;
+       return rc;
 }
 
 /*