]> git.sur5r.net Git - openldap/commitdiff
complete previous commit (protect binds)
authorPierangelo Masarati <ando@openldap.org>
Tue, 4 Apr 2006 18:45:59 +0000 (18:45 +0000)
committerPierangelo Masarati <ando@openldap.org>
Tue, 4 Apr 2006 18:45:59 +0000 (18:45 +0000)
servers/slapd/back-meta/bind.c
servers/slapd/back-meta/conn.c

index 82ece95fa06b16ff8867c066f153639d2ab97409..43f82973782011221749b4faa1922405b8a2c3a9 100644 (file)
@@ -577,6 +577,7 @@ retry:;
                                                mt, mc, candidate,
                                                LDAP_BACK_CONN_ISPRIV( mc ),
                                                LDAP_BACK_DONTSEND );
+                                       LDAP_BACK_CONN_BINDING_SET( msc );
 
                                } else {
                                        /* can't do anything about it */
@@ -614,6 +615,7 @@ retry:;
 done:;
        rs->sr_err = rc;
        if ( rc != LDAP_SUCCESS && META_BACK_ONERR_STOP( mi ) ) {
+               LDAP_BACK_CONN_BINDING_CLEAR( msc );
                meta_back_release_conn_lock( op, mc, 1, dolock );
                *mcp = NULL;
 
@@ -713,14 +715,23 @@ retry:;
                                goto send_err;
                        }
 
+
                        if ( rc == LDAP_UNAVAILABLE && do_retry ) {
                                do_retry = 0;
                                if ( meta_back_retry( op, rs, &mc, i, sendok ) ) {
                                        goto retry;
                                }
+                               ldap_pvt_thread_mutex_lock( &mi->mi_conninfo.lai_mutex );
+                               LDAP_BACK_CONN_BINDING_CLEAR( msc );
+                               ldap_pvt_thread_mutex_unlock( &mi->mi_conninfo.lai_mutex );
+
                                return 0;
                        }
 
+                       ldap_pvt_thread_mutex_lock( &mi->mi_conninfo.lai_mutex );
+                       LDAP_BACK_CONN_BINDING_CLEAR( msc );
+                       ldap_pvt_thread_mutex_unlock( &mi->mi_conninfo.lai_mutex );
+
                        snprintf( buf, sizeof( buf ),
                                "meta_back_dobind[%d]: (%s) err=%d (%s).",
                                i, rootdn ? rootdn : "anonymous",
index 9faa12d7ac550421bf26b6a3a269fc276a2d6c61..657881ca50df5126f4ea764f57585ada0420f4cd 100644 (file)
@@ -488,9 +488,10 @@ meta_back_retry(
 {
        metainfo_t              *mi = ( metainfo_t * )op->o_bd->be_private;
        metatarget_t            *mt = &mi->mi_targets[ candidate ];
-       int                     rc = LDAP_UNAVAILABLE;
        metaconn_t              *mc = *mcp;
        metasingleconn_t        *msc = &mc->mc_conns[ candidate ];
+       int                     rc = LDAP_UNAVAILABLE,
+                               binding = LDAP_BACK_CONN_BINDING( msc );
 
        ldap_pvt_thread_mutex_lock( &mi->mi_conninfo.lai_mutex );
 
@@ -515,6 +516,9 @@ meta_back_retry(
                /* mc here must be the regular mc, reset and ready for init */
                rc = meta_back_init_one_conn( op, rs, mt, mc, candidate,
                        LDAP_BACK_CONN_ISPRIV( mc ), sendok );
+               if ( binding ) {
+                       LDAP_BACK_CONN_BINDING_SET( msc );
+               }
 
                if ( rc == LDAP_SUCCESS ) {
                        rc = meta_back_single_dobind( op, rs, mcp, candidate,
@@ -524,6 +528,9 @@ meta_back_retry(
 
        if ( rc != LDAP_SUCCESS ) {
                if ( *mcp != NULL ) {
+                       if ( binding ) {
+                               LDAP_BACK_CONN_BINDING_CLEAR( msc );
+                       }
                        meta_back_release_conn_lock( op, mc, 1, 0 );
                        *mcp = NULL;
                }