]> git.sur5r.net Git - openldap/commitdiff
rework quarantine locking and so
authorPierangelo Masarati <ando@openldap.org>
Wed, 7 Jun 2006 23:25:38 +0000 (23:25 +0000)
committerPierangelo Masarati <ando@openldap.org>
Wed, 7 Jun 2006 23:25:38 +0000 (23:25 +0000)
17 files changed:
servers/slapd/back-ldap/back-ldap.h
servers/slapd/back-ldap/bind.c
servers/slapd/back-ldap/config.c
servers/slapd/back-ldap/extended.c
servers/slapd/back-ldap/init.c
servers/slapd/back-ldap/proto-ldap.h
servers/slapd/back-ldap/search.c
servers/slapd/back-meta/add.c
servers/slapd/back-meta/back-meta.h
servers/slapd/back-meta/bind.c
servers/slapd/back-meta/config.c
servers/slapd/back-meta/conn.c
servers/slapd/back-meta/delete.c
servers/slapd/back-meta/init.c
servers/slapd/back-meta/modify.c
servers/slapd/back-meta/modrdn.c
servers/slapd/back-meta/search.c

index 5b9632ddee5aec86765131e86bedd9e036d8583e..3df8356d1519d52345509091bef00d5542a4a26b 100644 (file)
@@ -251,14 +251,14 @@ typedef struct ldapinfo_t {
 
        ldap_avl_info_t li_conninfo;
 
-       slap_retry_info_t       li_quarantine;
-       /* NOTE: quarantine uses the connection mutex */
        sig_atomic_t            li_isquarantined;
 #define        LDAP_BACK_FQ_NO         (0)
 #define        LDAP_BACK_FQ_YES        (1)
 #define        LDAP_BACK_FQ_RETRYING   (2)
 
+       slap_retry_info_t       li_quarantine;
 #define        LDAP_BACK_QUARANTINE(li)        ( (li)->li_quarantine.ri_num != NULL )
+       ldap_pvt_thread_mutex_t li_quarantine_mutex;
        ldap_back_quarantine_f  li_quarantine_f;
        void                    *li_quarantine_p;
 
index 9b7fa5f4ad463f181a80fe16af9ab888be8852ee..b3433d322ab3cd24cdf0378a82b6a6dd8bb43e24 100644 (file)
@@ -608,7 +608,7 @@ ldap_back_getconn( Operation *op, SlapReply *rs, ldap_back_send_t sendok )
                slap_retry_info_t       *ri = &li->li_quarantine;
                int                     dont_retry = 1;
 
-               ldap_pvt_thread_mutex_lock( &li->li_conninfo.lai_mutex );
+               ldap_pvt_thread_mutex_lock( &li->li_quarantine_mutex );
                if ( li->li_isquarantined == LDAP_BACK_FQ_YES ) {
                        dont_retry = ( ri->ri_num[ ri->ri_idx ] == SLAP_RETRYNUM_TAIL
                                || slap_get_time() < ri->ri_last + ri->ri_interval[ ri->ri_idx ] );
@@ -620,7 +620,7 @@ ldap_back_getconn( Operation *op, SlapReply *rs, ldap_back_send_t sendok )
                                li->li_isquarantined = LDAP_BACK_FQ_RETRYING;
                        }
                }
-               ldap_pvt_thread_mutex_unlock( &li->li_conninfo.lai_mutex );
+               ldap_pvt_thread_mutex_unlock( &li->li_quarantine_mutex );
 
                if ( dont_retry ) {
                        rs->sr_err = LDAP_UNAVAILABLE;
@@ -837,16 +837,13 @@ ldap_back_release_conn_lock(
 void
 ldap_back_quarantine(
        Operation       *op,
-       SlapReply       *rs,
-       int             dolock )
+       SlapReply       *rs )
 {
        ldapinfo_t      *li = (ldapinfo_t *)op->o_bd->be_private;
 
        slap_retry_info_t       *ri = &li->li_quarantine;
 
-       if ( dolock ) {
-               ldap_pvt_thread_mutex_lock( &li->li_conninfo.lai_mutex );
-       }
+       ldap_pvt_thread_mutex_lock( &li->li_quarantine_mutex );
 
        if ( rs->sr_err == LDAP_UNAVAILABLE ) {
                switch ( li->li_isquarantined ) {
@@ -894,9 +891,7 @@ ldap_back_quarantine(
                li->li_isquarantined = LDAP_BACK_FQ_NO;
        }
 
-       if ( dolock ) {
-               ldap_pvt_thread_mutex_unlock( &li->li_conninfo.lai_mutex );
-       }
+       ldap_pvt_thread_mutex_unlock( &li->li_quarantine_mutex );
 }
 
 /*
@@ -1061,7 +1056,7 @@ retry_lock:;
                }
 
                if ( LDAP_BACK_QUARANTINE( li ) ) {
-                       ldap_back_quarantine( op, rs, dolock );
+                       ldap_back_quarantine( op, rs );
                }
 
                goto done;
@@ -1120,7 +1115,7 @@ retry:;
                rs->sr_err = slap_map_api2result( rs );
 
                if ( LDAP_BACK_QUARANTINE( li ) ) {
-                       ldap_back_quarantine( op, rs, dolock );
+                       ldap_back_quarantine( op, rs );
                }
 
                return 0;
@@ -1357,7 +1352,7 @@ retry:;
                }
        }
        if ( LDAP_BACK_QUARANTINE( li ) ) {
-               ldap_back_quarantine( op, rs, 1 );
+               ldap_back_quarantine( op, rs );
        }
        if ( op->o_conn &&
                ( ( sendok & LDAP_BACK_SENDOK ) 
@@ -1778,7 +1773,10 @@ ldap_back_proxy_authz_ctrl(
                goto done;
        }
 
-       if ( !BER_BVISNULL( &op->o_conn->c_ndn ) ) {
+       if ( op->o_tag == LDAP_REQ_BIND ) {
+               ndn = op->o_req_ndn;
+
+       } else if ( !BER_BVISNULL( &op->o_conn->c_ndn ) ) {
                ndn = op->o_conn->c_ndn;
 
        } else {
index 4088a982f21627b99bc5cf32cdd1a5a640cc1c19..14a44a51ed99627ab7e4d495fe752d3d52d3059a 100644 (file)
@@ -955,6 +955,7 @@ ldap_back_cf_gen( ConfigArgs *c )
                        }
 
                        slap_retry_info_destroy( &li->li_quarantine );
+                       ldap_pvt_thread_mutex_destroy( &li->li_quarantine_mutex );
                        li->li_isquarantined = 0;
                        break;
 
@@ -1654,10 +1655,13 @@ done_url:;
                        c->msg, sizeof( c->msg ) );
                if ( rc ) {
                        Debug( LDAP_DEBUG_ANY, "%s: %s.\n", c->log, c->msg, 0 );
+
+               } else {
+                       ldap_pvt_thread_mutex_init( &li->li_quarantine_mutex );
+                       /* give it a chance to retry if the pattern gets reset
+                        * via back-config */
+                       li->li_isquarantined = 0;
                }
-               /* give it a chance to retry if the pattern gets reset
-                * via back-config */
-               li->li_isquarantined = 0;
                break;
 
        case LDAP_BACK_CFG_REWRITE:
index 2e0974452b9dfc6c2059740cb8fe89855beb348e..0651ffe6851394272c6d32332a289fe85e2f587b 100644 (file)
@@ -185,7 +185,7 @@ retry:
                }
 
                if ( LDAP_BACK_QUARANTINE( li ) ) {
-                       ldap_back_quarantine( op, rs, 1 );
+                       ldap_back_quarantine( op, rs );
                }
 
                if ( text ) rs->sr_text = text;
@@ -194,7 +194,7 @@ retry:
                rc = rs->sr_err = SLAPD_ABANDON;
 
        } else if ( LDAP_BACK_QUARANTINE( li ) ) {
-               ldap_back_quarantine( op, rs, 1 );
+               ldap_back_quarantine( op, rs );
        }
 
        /* these have to be freed anyway... */
@@ -281,7 +281,7 @@ retry:
                }
 
                if ( LDAP_BACK_QUARANTINE( li ) ) {
-                       ldap_back_quarantine( op, rs, 1 );
+                       ldap_back_quarantine( op, rs );
                }
 
                if ( text ) rs->sr_text = text;
@@ -290,7 +290,7 @@ retry:
                rc = rs->sr_err = SLAPD_ABANDON;
 
        } else if ( LDAP_BACK_QUARANTINE( li ) ) {
-               ldap_back_quarantine( op, rs, 1 );
+               ldap_back_quarantine( op, rs );
        }
 
        /* these have to be freed anyway... */
index 2b96dae787ece38d173232d7e3b7d95b99572128..396eb912e55805794ff14c1f46ca0071161f5974 100644 (file)
@@ -319,6 +319,7 @@ ldap_back_db_destroy(
                }
                if ( LDAP_BACK_QUARANTINE( li ) ) {
                        slap_retry_info_destroy( &li->li_quarantine );
+                       ldap_pvt_thread_mutex_destroy( &li->li_quarantine_mutex );
                }
 
                ldap_pvt_thread_mutex_unlock( &li->li_conninfo.lai_mutex );
index b9c4e727b305bd8bf4d241817d61810c06027c5b..bb4baf29248cdfb1818cf28c8898f1f439d2ef35 100644 (file)
@@ -80,8 +80,7 @@ ldap_back_proxy_authz_ctrl_free(
 extern void
 ldap_back_quarantine(
        Operation       *op,
-       SlapReply       *rs,
-       int             dolock );
+       SlapReply       *rs );
 
 extern void slap_retry_info_destroy( slap_retry_info_t *ri );
 extern int slap_retry_info_parse( char *in, slap_retry_info_t *ri,
index eed46629d365cedddd7e5f4c3efeb0b9174e638d..4d95374f1e11e47df7a9d816c3e9445468e27d41 100644 (file)
@@ -467,7 +467,7 @@ retry:
 
 finish:;
        if ( LDAP_BACK_QUARANTINE( li ) ) {
-               ldap_back_quarantine( op, rs, 1 );
+               ldap_back_quarantine( op, rs );
        }
 
        if ( rc != SLAPD_ABANDON ) {
index 6a58cbeb9744d1e8c7952524c836687103a4bd12..af2663549f123e204b22c2b25a17f854f333fb49 100644 (file)
@@ -221,8 +221,8 @@ retry:;
        } else {
                send_ldap_result( op, rs );
 
-               if ( META_BACK_QUARANTINE( mi ) ) {
-                       meta_back_quarantine( op, rs, candidate, 1 );
+               if ( META_BACK_TGT_QUARANTINE( mi->mi_targets[ candidate ] ) ) {
+                       meta_back_quarantine( op, rs, candidate );
                }
        }
 
index 8d327adf2f6968e478584e6b59a7a4a2e3b93efc..c5a4ee4c1ffb899eafbf09025085eabb9d07fe27 100644 (file)
@@ -242,6 +242,8 @@ typedef struct metatarget_t {
 
        sig_atomic_t            mt_isquarantined;
        slap_retry_info_t       mt_quarantine;
+       ldap_pvt_thread_mutex_t mt_quarantine_mutex;
+#define        META_BACK_TGT_QUARANTINE(mt)    ( (mt)->mt_quarantine.ri_num != NULL )
 
        unsigned                mt_flags;
 #define        META_BACK_TGT_ISSET(mt,f)               ( ( (mt)->mt_flags & (f) ) == (f) )
@@ -371,8 +373,7 @@ extern void
 meta_back_quarantine(
        Operation               *op,
        SlapReply               *rs,
-       int                     candidate,
-       int                     dolock );
+       int                     candidate );
 
 extern int
 meta_back_single_bind(
index 9d1bc4e25cda28450e22b7c8ea507517bf123efa..0e2d4b1ac05e053fe4ad130ae45d3cbccbc18ee5 100644 (file)
@@ -78,17 +78,19 @@ meta_back_bind( Operation *op, SlapReply *rs )
         * invalidCredentials */
        mc = meta_back_getconn( op, rs, NULL, LDAP_BACK_BIND_DONTSEND );
        if ( !mc ) {
-               char    buf[ SLAP_TEXT_BUFLEN ];
-
-               snprintf( buf, sizeof( buf ),
-                       "meta_back_bind: no target "
-                       "for dn \"%s\" (%d%s%s).",
-                       op->o_req_dn.bv_val, rs->sr_err,
-                       rs->sr_text ? ". " : "",
-                       rs->sr_text ? rs->sr_text : "" );
-               Debug( LDAP_DEBUG_ANY,
-                       "%s %s\n",
-                       op->o_log_prefix, buf, 0 );
+               if ( LogTest( LDAP_DEBUG_ANY ) ) {
+                       char    buf[ SLAP_TEXT_BUFLEN ];
+
+                       snprintf( buf, sizeof( buf ),
+                               "meta_back_bind: no target "
+                               "for dn \"%s\" (%d%s%s).",
+                               op->o_req_dn.bv_val, rs->sr_err,
+                               rs->sr_text ? ". " : "",
+                               rs->sr_text ? rs->sr_text : "" );
+                       Debug( LDAP_DEBUG_ANY,
+                               "%s %s\n",
+                               op->o_log_prefix, buf, 0 );
+               }
 
                /* FIXME: there might be cases where we don't want
                 * to map the error onto invalidCredentials */
@@ -453,8 +455,8 @@ return_results:;
                free( mdn.bv_val );
        }
 
-       if ( META_BACK_QUARANTINE( mi ) ) {
-               meta_back_quarantine( op, rs, candidate, 1 );
+       if ( META_BACK_TGT_QUARANTINE( mt ) ) {
+               meta_back_quarantine( op, rs, candidate );
        }
 
        return rs->sr_err;
@@ -659,8 +661,8 @@ done:;
                }
        }
 
-       if ( META_BACK_QUARANTINE( mi ) ) {
-               meta_back_quarantine( op, rs, candidate, dolock );
+       if ( META_BACK_TGT_QUARANTINE( mt ) ) {
+               meta_back_quarantine( op, rs, candidate );
        }
 
        return rc;
@@ -982,15 +984,14 @@ meta_back_op_result(
                        rerr = rs->sr_err = slap_map_api2result( rs );
 
                        Debug(LDAP_DEBUG_ANY,
-                                       "==> meta_back_op_result: target"
-                                       " <%d> sending msg \"%s\""
-                                       " (matched \"%s\")\n", 
+                                       "==> meta_back_op_result[%d] "
+                                       "text=\"%s\" matched=\"%s\"\n", 
                                        candidate, ( rmsg ? rmsg : "" ),
                                        ( rmatch ? rmatch : "" ) );
                }
 
-               if ( META_BACK_QUARANTINE( mi ) ) {
-                       meta_back_quarantine( op, rs, candidate, 1 );
+               if ( META_BACK_TGT_QUARANTINE( mi->mi_targets[ candidate ] ) ) {
+                       meta_back_quarantine( op, rs, candidate );
                }
 
        } else {
@@ -1026,9 +1027,8 @@ meta_back_op_result(
                                rs->sr_err = slap_map_api2result( rs );
        
                                Debug(LDAP_DEBUG_ANY,
-                                               "==> meta_back_op_result: target"
-                                               " <%d> sending msg \"%s\""
-                                               " (matched \"%s\")\n", 
+                                               "==> meta_back_op_result[%d] "
+                                               "text=\"%s\" matched=\"%s\"\n", 
                                                i, ( msg ? msg : "" ),
                                                ( match ? match : "" ) );
        
@@ -1064,8 +1064,8 @@ meta_back_op_result(
                                }
                        }
 
-                       if ( META_BACK_QUARANTINE( mi ) ) {
-                               meta_back_quarantine( op, rs, i, 1 );
+                       if ( META_BACK_TGT_QUARANTINE( mi->mi_targets[ i ] ) ) {
+                               meta_back_quarantine( op, rs, i );
                        }
                }
        }
index 80397af15b7d20f9906de23730e1e0ae28c6f179..555d51b7e63ffaeb59cf298b0abe1dd719f87939 100644 (file)
@@ -172,6 +172,9 @@ meta_back_db_config(
 
                mt->mt_nretries = mi->mi_nretries;
                mt->mt_quarantine = mi->mi_quarantine;
+               if ( META_BACK_QUARANTINE( mi ) ) {
+                       ldap_pvt_thread_mutex_init( &mt->mt_quarantine_mutex );
+               }
                mt->mt_flags = mi->mi_flags;
                mt->mt_version = mi->mi_version;
                mt->mt_network_timeout = mi->mi_network_timeout;
@@ -990,7 +993,9 @@ meta_back_db_config(
                                &mi->mi_targets[ mi->mi_ntargets - 1 ]->mt_quarantine
                                : &mi->mi_quarantine;
 
-               if ( META_BACK_QUARANTINE( mi ) ) {
+               if ( ( mi->mi_ntargets == 0 && META_BACK_QUARANTINE( mi ) )
+                       || ( mi->mi_ntargets > 0 && META_BACK_TGT_QUARANTINE( mi->mi_targets[ mi->mi_ntargets - 1 ] ) ) )
+               {
                        Debug( LDAP_DEBUG_ANY,
                                "%s: line %d: quarantine already defined.\n",
                                fname, lineno, 0 );
@@ -1019,6 +1024,10 @@ meta_back_db_config(
                        ri->ri_num = NULL;
                }
 
+               if ( mi->mi_ntargets > 0 && !META_BACK_QUARANTINE( mi ) ) {
+                       ldap_pvt_thread_mutex_init( &mi->mi_targets[ mi->mi_ntargets - 1 ]->mt_quarantine_mutex );
+               }
+
                if ( slap_retry_info_parse( argv[ 1 ], ri, buf, sizeof( buf ) ) ) {
                        Debug( LDAP_DEBUG_ANY,
                                "%s line %d: %s.\n",
index 23c6b5fddc19301e36b4d6a371a6dd068f7fb2f8..3339ad7d2d10b29252a84f84f93ae3360cf1c897 100644 (file)
@@ -489,7 +489,7 @@ retry:;
                                goto error_return;
                        }
                        
-                       /* copy the DN if needed */
+                       /* copy the DN idf 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 );
                        }
@@ -615,8 +615,8 @@ meta_back_retry(
                }
        }
 
-       if ( META_BACK_QUARANTINE( mi ) ) {
-               meta_back_quarantine( op, rs, candidate, 0 );
+       if ( META_BACK_TGT_QUARANTINE( mt ) ) {
+               meta_back_quarantine( op, rs, candidate );
        }
 
        ldap_pvt_thread_mutex_unlock( &mi->mi_conninfo.lai_mutex );
@@ -876,8 +876,7 @@ meta_back_getconn(
        /* Explicit Bind requests always get their own conn */
        if ( !( sendok & LDAP_BACK_BINDING ) ) {
                /* Searches for a metaconn in the avl tree */
-retry_lock:
-               new_conn = 0;
+retry_lock:;
                ldap_pvt_thread_mutex_lock( &mi->mi_conninfo.lai_mutex );
                mc = (metaconn_t *)avl_find( mi->mi_conninfo.lai_tree, 
                        (caddr_t)&mc_curr, meta_back_conndn_cmp );
@@ -1209,8 +1208,14 @@ retry_lock2:;
                                        candidates[ i ].sr_err = lerr;
                                        err = lerr;
 
-                                       Debug( LDAP_DEBUG_ANY, "%s: meta_back_getconn[%d] failed: %d\n",
-                                               op->o_log_prefix, i, lerr );
+                                       if ( lerr == LDAP_UNAVAILABLE && mt->mt_isquarantined != LDAP_BACK_FQ_NO ) {
+                                               Debug( LDAP_DEBUG_TRACE, "%s: meta_back_getconn[%d] quarantined: %d\n",
+                                                       op->o_log_prefix, i, lerr );
+
+                                       } else {
+                                               Debug( LDAP_DEBUG_ANY, "%s: meta_back_getconn[%d] failed: %d\n",
+                                                       op->o_log_prefix, i, lerr );
+                                       }
 
                                        if ( META_BACK_ONERR_STOP( mi ) ) {
                                                if ( sendok & LDAP_BACK_SENDERR ) {
@@ -1299,8 +1304,9 @@ done:;
                        break;
 
                case -1:
+                       /* duplicate: free and try to get the newly created one */
                        if ( !( sendok & LDAP_BACK_BINDING ) ) {
-                               /* duplicate: free and try to get the newly created one */
+                               new_conn = 0;
                                goto retry_lock;
                        }
                        LDAP_BACK_CONN_TAINTED_SET( mc );
@@ -1373,33 +1379,36 @@ void
 meta_back_quarantine(
        Operation       *op,
        SlapReply       *rs,
-       int             candidate,
-       int             dolock )
+       int             candidate )
 {
        metainfo_t              *mi = (metainfo_t *)op->o_bd->be_private;
        metatarget_t            *mt = mi->mi_targets[ candidate ];
 
        slap_retry_info_t       *ri = &mt->mt_quarantine;
 
-       if ( dolock ) {
-               ldap_pvt_thread_mutex_lock( &mi->mi_conninfo.lai_mutex );
-       }
+       ldap_pvt_thread_mutex_lock( &mt->mt_quarantine_mutex );
 
        if ( rs->sr_err == LDAP_UNAVAILABLE ) {
                switch ( mt->mt_isquarantined ) {
                case LDAP_BACK_FQ_NO:
                        Debug( LDAP_DEBUG_ANY,
-                               "%s: meta_back_quarantine enter.\n",
-                               op->o_log_prefix, 0, 0 );
+                               "%s: meta_back_quarantine[%d] enter.\n",
+                               op->o_log_prefix, candidate, 0 );
 
                        ri->ri_idx = 0;
                        ri->ri_count = 0;
                        break;
 
                case LDAP_BACK_FQ_RETRYING:
-                       Debug( LDAP_DEBUG_ANY,
-                               "%s: meta_back_quarantine block #%d try #%d failed.\n",
-                               op->o_log_prefix, ri->ri_idx, ri->ri_count );
+                       if ( LogTest( LDAP_DEBUG_ANY ) ) {
+                               char    buf[ SLAP_TEXT_BUFLEN ];
+
+                               snprintf( buf, sizeof( buf ),
+                                       "meta_back_quarantine[%d] block #%d try #%d failed",
+                                       candidate, ri->ri_idx, ri->ri_count );
+                               Debug( LDAP_DEBUG_ANY, "%s: %s.\n",
+                                       op->o_log_prefix, buf, 0 );
+                       }
 
                        ++ri->ri_count;
                        if ( ri->ri_num[ ri->ri_idx ] != SLAP_RETRYNUM_FOREVER
@@ -1417,10 +1426,10 @@ meta_back_quarantine(
                mt->mt_isquarantined = LDAP_BACK_FQ_YES;
                ri->ri_last = slap_get_time();
 
-       } else if ( mt->mt_isquarantined != LDAP_BACK_FQ_NO ) {
+       } else if ( mt->mt_isquarantined == LDAP_BACK_FQ_RETRYING ) {
                Debug( LDAP_DEBUG_ANY,
-                       "%s: meta_back_quarantine exit.\n",
-                       op->o_log_prefix, ri->ri_idx, ri->ri_count );
+                       "%s: meta_back_quarantine[%d] exit.\n",
+                       op->o_log_prefix, candidate, 0 );
 
                if ( mi->mi_quarantine_f ) {
                        (void)mi->mi_quarantine_f( mi, candidate,
@@ -1432,8 +1441,6 @@ meta_back_quarantine(
                mt->mt_isquarantined = LDAP_BACK_FQ_NO;
        }
 
-       if ( dolock ) {
-               ldap_pvt_thread_mutex_unlock( &mi->mi_conninfo.lai_mutex );
-       }
+       ldap_pvt_thread_mutex_unlock( &mt->mt_quarantine_mutex );
 }
 
index 812f01d66768cbcd23ba784aaa08f9dc9ce6c942..bb29bcb177156f764523dfbd91c701d2a703d003 100644 (file)
@@ -120,8 +120,8 @@ retry:;
        } else {
                send_ldap_result( op, rs );
 
-               if ( META_BACK_QUARANTINE( mi ) ) {
-                       meta_back_quarantine( op, rs, candidate, 1 );
+               if ( META_BACK_TGT_QUARANTINE( mi->mi_targets[ candidate ] ) ) {
+                       meta_back_quarantine( op, rs, candidate );
                }
        }
 
index 914b18813d9919b5ac90991ac3310ba6d105f23a..df3b7dfc6954a5b0c66e04d93eaeb83278a9cf4d 100644 (file)
@@ -267,13 +267,18 @@ meta_back_db_destroy(
                 */
                if ( mi->mi_targets != NULL ) {
                        for ( i = 0; i < mi->mi_ntargets; i++ ) {
-                               if ( META_BACK_QUARANTINE( mi )
-                                       && mi->mi_targets[ i ]->mt_quarantine.ri_num != mi->mi_quarantine.ri_num )
-                               {
-                                       slap_retry_info_destroy( &mi->mi_targets[ i ]->mt_quarantine );
+                               metatarget_t    *mt = mi->mi_targets[ i ];
+
+                               if ( META_BACK_TGT_QUARANTINE( mt ) ) {
+                                       if ( mt->mt_quarantine.ri_num != mi->mi_quarantine.ri_num )
+                                       {
+                                               slap_retry_info_destroy( &mt->mt_quarantine );
+                                       }
+
+                                       ldap_pvt_thread_mutex_destroy( &mt->mt_quarantine_mutex );
                                }
 
-                               target_free( mi->mi_targets[ i ] );
+                               target_free( mt );
                        }
 
                        free( mi->mi_targets );
index 29583faa1e3dbe4bac7a6a2d6d8f28ec5c100c65..00c1d629770063a81e1b2ba59fa9063db08067e4 100644 (file)
@@ -232,8 +232,8 @@ cleanup:;
        } else {
                send_ldap_result( op, rs );
 
-               if ( META_BACK_QUARANTINE( mi ) ) {
-                       meta_back_quarantine( op, rs, candidate, 1 );
+               if ( META_BACK_TGT_QUARANTINE( mi->mi_targets[ candidate ] ) ) {
+                       meta_back_quarantine( op, rs, candidate );
                }
        }
 
index fb739fa1c0811d197849417caf496991e07fce9c..16a3f1320de88433485cf8eb51a15a0c86bb3ec3 100644 (file)
@@ -176,8 +176,8 @@ cleanup:;
        } else {
                send_ldap_result( op, rs );
 
-               if ( META_BACK_QUARANTINE( mi ) ) {
-                       meta_back_quarantine( op, rs, candidate, 1 );
+               if ( META_BACK_TGT_QUARANTINE( mi->mi_targets[ candidate ] ) ) {
+                       meta_back_quarantine( op, rs, candidate );
                }
        }
 
index b329ab54f794144ac5a8062f8004d3ce59ec351b..17493f2391e2ea8f3940287f55b99d2324aa3246 100644 (file)
@@ -1271,8 +1271,8 @@ finish:;
                        candidates[ i ].sr_ctrls = NULL;
                }
 
-               if ( META_BACK_QUARANTINE( mi ) ) {
-                       meta_back_quarantine( op, &candidates[ i ], i, 1 );
+               if ( META_BACK_TGT_QUARANTINE( mi->mi_targets[ i ] ) ) {
+                       meta_back_quarantine( op, &candidates[ i ], i );
                }
        }