]> git.sur5r.net Git - openldap/blobdiff - servers/slapd/syncrepl.c
ITS#6054 quit using global malloc
[openldap] / servers / slapd / syncrepl.c
index 215f657aa9ea3d7b2847a5e20f0953710946952b..11ad325d7603cb381a4415355545a036a1d5614a 100644 (file)
@@ -1302,10 +1302,6 @@ do_syncrepl(
        connection_fake_init( &conn, &opbuf, ctx );
        op = &opbuf.ob_op;
 
-       /* use global malloc for now */
-       op->o_tmpmemctx = NULL;
-       op->o_tmpmfuncs = &ch_mfuncs;
-
        op->o_managedsait = SLAP_CONTROL_NONCRITICAL;
        be = si->si_be;
 
@@ -3605,12 +3601,8 @@ syncinfo_free( syncinfo_t *sie, int free_all )
                sie->si_ridtxt, 0, 0 );
 
        do {
-               struct re_s             *re;
-
                si_next = sie->si_next;
 
-               sie->si_re = NULL;
-
                if ( sie->si_ld ) {
                        if ( sie->si_conn ) {
                                connection_client_stop( sie->si_conn );
@@ -3619,20 +3611,21 @@ syncinfo_free( syncinfo_t *sie, int free_all )
                        ldap_unbind_ext( sie->si_ld, NULL, NULL );
                }
        
-               /* re-fetch it, in case it was already removed */
-               ldap_pvt_thread_mutex_lock( &slapd_rq.rq_mutex );
-               re = ldap_pvt_runqueue_find( &slapd_rq, do_syncrepl, sie );
-               if ( re ) {
+               if ( sie->si_re ) {
+                       struct re_s             *re = sie->si_re;
+                       sie->si_re = NULL;
+
+                       ldap_pvt_thread_mutex_lock( &slapd_rq.rq_mutex );
                        if ( ldap_pvt_runqueue_isrunning( &slapd_rq, re ) )
                                ldap_pvt_runqueue_stoptask( &slapd_rq, re );
                        ldap_pvt_runqueue_remove( &slapd_rq, re );
+                       ldap_pvt_thread_mutex_unlock( &slapd_rq.rq_mutex );
                }
-       
-               ldap_pvt_thread_mutex_unlock( &slapd_rq.rq_mutex );
-               ldap_pvt_thread_mutex_destroy( &sie->si_mutex );
-       
+
+               ldap_pvt_thread_mutex_destroy( &sie->si_mutex );
+
                bindconf_free( &sie->si_bindconf );
-       
+
                if ( sie->si_filterstr.bv_val ) {
                        ch_free( sie->si_filterstr.bv_val );
                }
@@ -4608,24 +4601,24 @@ syncrepl_config( ConfigArgs *c )
                                        if ( si->si_re ) {
                                                if ( ldap_pvt_thread_mutex_trylock( &si->si_mutex )) {
                                                        isrunning = 1;
-                                               } else if ( si->si_conn ) {
-                                                       isrunning = 1;
-                                                       /* If there's a persistent connection, we don't
-                                                        * know if it's already got a thread queued.
-                                                        * so defer the free, but reschedule the task.
-                                                        * If there's a connection thread queued, it
-                                                        * will cleanup as necessary. If not, then the
-                                                        * runqueue task will cleanup.
-                                                        */
-                                                       ldap_pvt_thread_mutex_lock( &slapd_rq.rq_mutex );
-                                                       if ( !ldap_pvt_runqueue_isrunning( &slapd_rq, si->si_re )) {
-                                                               si->si_re->interval.tv_sec = 0;
-                                                               ldap_pvt_runqueue_resched( &slapd_rq, si->si_re, 0 );
-                                                               si->si_re->interval.tv_sec = si->si_interval;
-                                                       }
-                                                       ldap_pvt_thread_mutex_unlock( &slapd_rq.rq_mutex );
-
                                                } else {
+                                                       if ( si->si_conn ) {
+                                                               isrunning = 1;
+                                                               /* If there's a persistent connection, we don't
+                                                                * know if it's already got a thread queued.
+                                                                * so defer the free, but reschedule the task.
+                                                                * If there's a connection thread queued, it
+                                                                * will cleanup as necessary. If not, then the
+                                                                * runqueue task will cleanup.
+                                                                */
+                                                               ldap_pvt_thread_mutex_lock( &slapd_rq.rq_mutex );
+                                                               if ( !ldap_pvt_runqueue_isrunning( &slapd_rq, si->si_re )) {
+                                                                       si->si_re->interval.tv_sec = 0;
+                                                                       ldap_pvt_runqueue_resched( &slapd_rq, si->si_re, 0 );
+                                                                       si->si_re->interval.tv_sec = si->si_interval;
+                                                               }
+                                                               ldap_pvt_thread_mutex_unlock( &slapd_rq.rq_mutex );
+                                                       }
                                                        ldap_pvt_thread_mutex_unlock( &si->si_mutex );
                                                }
                                        }