]> git.sur5r.net Git - openldap/commitdiff
ITS#3546 fix consumer crash on interrupt (provider crash still unresolved)
authorHoward Chu <hyc@openldap.org>
Thu, 17 Feb 2005 15:07:27 +0000 (15:07 +0000)
committerHoward Chu <hyc@openldap.org>
Thu, 17 Feb 2005 15:07:27 +0000 (15:07 +0000)
servers/slapd/config.c
servers/slapd/slap.h
servers/slapd/syncrepl.c

index 8695fcd11c83a8b6544acdac4fd1ffa4b4dfd7f7..4dd2032b810f2fc40827292055575623c35832af 100644 (file)
@@ -1671,6 +1671,7 @@ add_syncrepl(
 
        si->si_presentlist = NULL;
        LDAP_LIST_INIT( &si->si_nonpresentlist );
+       ldap_pvt_thread_mutex_init( &si->si_mutex );
 
        rc = parse_syncrepl_line( cargv, cargc, si );
 
index 568cdd2334f4f7cbccbca6fbcec59291fc67a094..799a5b7d8a41e519533cb6d8c51d26545376e6cd 100644 (file)
@@ -1524,6 +1524,7 @@ typedef struct syncinfo_s {
         Avlnode                                *si_presentlist;
                LDAP                            *si_ld;
                LDAP_LIST_HEAD(np, nonpresent_entry) si_nonpresentlist;
+               ldap_pvt_thread_mutex_t si_mutex;
 } syncinfo_t;
 
 LDAP_TAILQ_HEAD( be_pcl, slap_csn_entry );
index 7794fda4269a351f8883f30ae32f997375f6edaa..f9da2a59c594fc139601f09ca60af4d91e6918a6 100644 (file)
@@ -527,6 +527,10 @@ do_syncrep2(
                        msg != NULL;
                        msg = ldap_next_message( si->si_ld, msg ) )
                {
+                       if ( slapd_shutdown ) {
+                               rc = -2;
+                               goto done;
+                       }
                        switch( ldap_msgtype( msg ) ) {
                        case LDAP_RES_SEARCH_ENTRY:
                                ldap_get_entry_controls( si->si_ld, msg, &rctrls );
@@ -839,11 +843,14 @@ do_syncrepl(
        if ( si == NULL )
                return NULL;
 
+       ldap_pvt_thread_mutex_lock( &si->si_mutex );
+
        switch( abs( si->si_type )) {
        case LDAP_SYNC_REFRESH_ONLY:
        case LDAP_SYNC_REFRESH_AND_PERSIST:
                break;
        default:
+               ldap_pvt_thread_mutex_unlock( &si->si_mutex );
                return NULL;
        }
 
@@ -854,6 +861,7 @@ do_syncrepl(
                        ldap_unbind( si->si_ld );
                        si->si_ld = NULL;
                }
+               ldap_pvt_thread_mutex_unlock( &si->si_mutex );
                return NULL;
        }
 
@@ -947,6 +955,7 @@ do_syncrepl(
        }
        
        ldap_pvt_thread_mutex_unlock( &slapd_rq.rq_mutex );
+       ldap_pvt_thread_mutex_unlock( &si->si_mutex );
 
        return NULL;
 }
@@ -2074,6 +2083,7 @@ avl_ber_bvfree( void *v_bv )
 void
 syncinfo_free( syncinfo_t *sie )
 {
+       ldap_pvt_thread_mutex_destroy( &sie->si_mutex );
        if ( !BER_BVISNULL( &sie->si_provideruri ) ) {
                ch_free( sie->si_provideruri.bv_val );
        }