]> git.sur5r.net Git - openldap/commitdiff
destroy bind connection after failed bind (ITS#4428)
authorPierangelo Masarati <ando@openldap.org>
Sat, 25 Mar 2006 00:33:42 +0000 (00:33 +0000)
committerPierangelo Masarati <ando@openldap.org>
Sat, 25 Mar 2006 00:33:42 +0000 (00:33 +0000)
servers/slapd/back-ldap/bind.c

index 27888d19d03177afb135f1b1a37684e493199ad8..06b069bdb8f926bdc17fcda4e63159f59c1a5300 100644 (file)
@@ -91,8 +91,6 @@ ldap_back_bind( Operation *op, SlapReply *rs )
                        }
                }
 
-               assert( lc->lc_binding == 1 );
-               lc->lc_binding = 0;
                LDAP_BACK_CONN_ISBOUND_SET( lc );
                ber_dupbv( &lc->lc_bound_ndn, &op->o_req_ndn );
 
@@ -107,11 +105,15 @@ ldap_back_bind( Operation *op, SlapReply *rs )
        }
 done:;
 
+       assert( lc->lc_binding == 1 );
+       lc->lc_binding = 0;
+
        /* must re-insert if local DN changed as result of bind */
-       if ( LDAP_BACK_CONN_ISBOUND( lc )
-               && !dn_match( &op->o_req_ndn, &lc->lc_local_ndn ) )
+       if ( !LDAP_BACK_CONN_ISBOUND( lc )
+               || ( LDAP_BACK_CONN_ISBOUND( lc )
+                       && !dn_match( &op->o_req_ndn, &lc->lc_local_ndn ) ) )
        {
-               int             lerr;
+               int             lerr = 0;
 
                /* wait for all other ops to release the connection */
 retry_lock:;
@@ -127,9 +129,12 @@ retry_lock:;
                                ldap_back_conndn_cmp );
                assert( lc != NULL );
 
-               ber_bvreplace( &lc->lc_local_ndn, &op->o_req_ndn );
-               lerr = avl_insert( &li->li_conninfo.lai_tree, (caddr_t)lc,
-                       ldap_back_conndn_cmp, ldap_back_conndn_dup );
+               if ( LDAP_BACK_CONN_ISBOUND( lc ) ) {
+                       ber_bvreplace( &lc->lc_local_ndn, &op->o_req_ndn );
+                       lerr = avl_insert( &li->li_conninfo.lai_tree, (caddr_t)lc,
+                               ldap_back_conndn_cmp, ldap_back_conndn_dup );
+               }
+
                ldap_pvt_thread_mutex_unlock( &li->li_conninfo.lai_mutex );
                if ( lerr == -1 ) {
                        /* we can do this because lc_refcnt == 1 */