]> git.sur5r.net Git - openldap/commitdiff
make sure heavy concurrency doesn't cause quarantine loops
authorPierangelo Masarati <ando@openldap.org>
Sat, 10 Jun 2006 01:08:45 +0000 (01:08 +0000)
committerPierangelo Masarati <ando@openldap.org>
Sat, 10 Jun 2006 01:08:45 +0000 (01:08 +0000)
servers/slapd/back-ldap/bind.c
servers/slapd/back-meta/conn.c

index fd51c670a0bc091d872731d2113d90ed7a00c4ff..ca304aa165ab504088167dabc6e122d1793c679c 100644 (file)
@@ -846,8 +846,14 @@ ldap_back_quarantine(
        ldap_pvt_thread_mutex_lock( &li->li_quarantine_mutex );
 
        if ( rs->sr_err == LDAP_UNAVAILABLE ) {
+               time_t          new_last = slap_get_time();
+
                switch ( li->li_isquarantined ) {
                case LDAP_BACK_FQ_NO:
+                       if ( ri->ri_last == new_last ) {
+                               goto done;
+                       }
+
                        Debug( LDAP_DEBUG_ANY,
                                "%s: ldap_back_quarantine enter.\n",
                                op->o_log_prefix, 0, 0 );
@@ -875,7 +881,7 @@ ldap_back_quarantine(
                }
 
                li->li_isquarantined = LDAP_BACK_FQ_YES;
-               ri->ri_last = slap_get_time();
+               ri->ri_last = new_last;
 
        } else if ( li->li_isquarantined != LDAP_BACK_FQ_NO ) {
                Debug( LDAP_DEBUG_ANY,
@@ -891,6 +897,7 @@ ldap_back_quarantine(
                li->li_isquarantined = LDAP_BACK_FQ_NO;
        }
 
+done:;
        ldap_pvt_thread_mutex_unlock( &li->li_quarantine_mutex );
 }
 
index cfd61ec8166e63cce03a1a3db091b0f3f288d2bc..0f61ab2e21d28dc00076a1f40851d0622a17122f 100644 (file)
@@ -496,7 +496,7 @@ retry:;
                                goto error_return;
                        }
                        
-                       /* copy the DN idf needed */
+                       /* copy the DN if needed */
                        if ( msc->msc_bound_ndn.bv_val == op->o_conn->c_dn.bv_val ) {
                                ber_dupbv( &msc->msc_bound_ndn, &op->o_conn->c_dn );
                        }
@@ -1396,8 +1396,14 @@ meta_back_quarantine(
        ldap_pvt_thread_mutex_lock( &mt->mt_quarantine_mutex );
 
        if ( rs->sr_err == LDAP_UNAVAILABLE ) {
+               time_t  new_last = slap_get_time();
+
                switch ( mt->mt_isquarantined ) {
                case LDAP_BACK_FQ_NO:
+                       if ( ri->ri_last == new_last ) {
+                               goto done;
+                       }
+
                        Debug( LDAP_DEBUG_ANY,
                                "%s meta_back_quarantine[%d]: enter.\n",
                                op->o_log_prefix, candidate, 0 );
@@ -1431,7 +1437,7 @@ meta_back_quarantine(
                }
 
                mt->mt_isquarantined = LDAP_BACK_FQ_YES;
-               ri->ri_last = slap_get_time();
+               ri->ri_last = new_last;
 
        } else if ( mt->mt_isquarantined == LDAP_BACK_FQ_RETRYING ) {
                Debug( LDAP_DEBUG_ANY,
@@ -1448,6 +1454,7 @@ meta_back_quarantine(
                mt->mt_isquarantined = LDAP_BACK_FQ_NO;
        }
 
+done:;
        ldap_pvt_thread_mutex_unlock( &mt->mt_quarantine_mutex );
 }