]> git.sur5r.net Git - openldap/commitdiff
make sure only on bind at a time occurs; release resources only when appropriate
authorPierangelo Masarati <ando@openldap.org>
Tue, 4 Apr 2006 17:41:50 +0000 (17:41 +0000)
committerPierangelo Masarati <ando@openldap.org>
Tue, 4 Apr 2006 17:41:50 +0000 (17:41 +0000)
servers/slapd/back-meta/back-meta.h
servers/slapd/back-meta/bind.c
servers/slapd/back-meta/conn.c

index 43d5fa3da56920ec427aa6026406e7a11dfb15bf..9d6eba8ab8f216b0dac353d7146f1b950646d8d6 100644 (file)
@@ -167,12 +167,6 @@ typedef struct metasingleconn_t {
        /* NOTE: lc_lcflags is redefined to msc_mscflags to reuse the macros
         * defined for back-ldap */
 #define        lc_lcflags              msc_mscflags
-#if 0
-       int                     msc_bound;
-#define META_UNBOUND           0
-#define META_BOUND             1
-#define META_ANONYMOUS         2
-#endif
 
        struct metainfo_t       *msc_info;
 } metasingleconn_t;
index 1ca6a0a9e52dcbdb2a9b83851eae7b5711cb6d49..82ece95fa06b16ff8867c066f153639d2ab97409 100644 (file)
@@ -679,10 +679,23 @@ meta_back_dobind(
                /*
                 * If the target is already bound it is skipped
                 */
+
+retry_binding:;
+               ldap_pvt_thread_mutex_lock( &mi->mi_conninfo.lai_mutex );
                if ( LDAP_BACK_CONN_ISBOUND( msc ) || LDAP_BACK_CONN_ISANON( msc ) ) {
+                       ldap_pvt_thread_mutex_unlock( &mi->mi_conninfo.lai_mutex );
                        ++bound;
                        continue;
-               }
+
+               } else if ( LDAP_BACK_CONN_BINDING( msc ) ) {
+                       ldap_pvt_thread_mutex_unlock( &mi->mi_conninfo.lai_mutex );
+                       ldap_pvt_thread_yield();
+                       goto retry_binding;
+
+               } else {
+                       LDAP_BACK_CONN_BINDING_SET( msc );
+                       ldap_pvt_thread_mutex_unlock( &mi->mi_conninfo.lai_mutex );
+               } 
 
 retry:;
                rc = meta_back_single_dobind( op, rs, &mc, i,
@@ -739,11 +752,14 @@ retry:;
                        op->o_log_prefix, i,
                        rootdn ? rootdn : "anonymous" );
 
+               ldap_pvt_thread_mutex_lock( &mi->mi_conninfo.lai_mutex );
+               LDAP_BACK_CONN_BINDING_CLEAR( msc );
                if ( rootdn ) {
                        LDAP_BACK_CONN_ISBOUND_SET( msc );
                } else {
                        LDAP_BACK_CONN_ISANON_SET( msc );
                }
+               ldap_pvt_thread_mutex_unlock( &mi->mi_conninfo.lai_mutex );
                ++bound;
        }
 
index 5b516c6d2b57c1cbd57cd50d48b99bce6f88804a..9faa12d7ac550421bf26b6a3a269fc276a2d6c61 100644 (file)
@@ -213,7 +213,7 @@ metaconn_alloc(
                mc->mc_conns[ i ].msc_ld = NULL;
                BER_BVZERO( &mc->mc_conns[ i ].msc_bound_ndn );
                BER_BVZERO( &mc->mc_conns[ i ].msc_cred );
-               LDAP_BACK_CONN_ISBOUND_CLEAR( &mc->mc_conns[ i ] );
+               mc->mc_conns[ i ].msc_mscflags = 0;
                mc->mc_conns[ i ].msc_info = mi;
        }
 
@@ -270,6 +270,8 @@ meta_back_init_one_conn(
        if ( msc->msc_ld != NULL ) {
                return rs->sr_err = LDAP_SUCCESS;
        }
+
+       msc->msc_mscflags = 0;
        
        /*
         * Attempts to initialize the connection to the target ds
@@ -453,8 +455,6 @@ retry:;
 
        assert( !BER_BVISNULL( &msc->msc_bound_ndn ) );
 
-       LDAP_BACK_CONN_ISBOUND_CLEAR( msc );
-
 error_return:;
        if ( rs->sr_err == LDAP_SUCCESS ) {
                /*
@@ -523,8 +523,10 @@ meta_back_retry(
        }
 
        if ( rc != LDAP_SUCCESS ) {
-               meta_back_release_conn_lock( op, mc, 1, 0 );
-               *mcp = NULL;
+               if ( *mcp != NULL ) {
+                       meta_back_release_conn_lock( op, mc, 1, 0 );
+                       *mcp = NULL;
+               }
 
                if ( sendok ) {
                        rs->sr_err = LDAP_UNAVAILABLE;