From 3b34a6f81c8715c257c24504f3457a7997139163 Mon Sep 17 00:00:00 2001 From: Howard Chu Date: Thu, 17 Feb 2005 15:07:27 +0000 Subject: [PATCH] ITS#3546 fix consumer crash on interrupt (provider crash still unresolved) --- servers/slapd/config.c | 1 + servers/slapd/slap.h | 1 + servers/slapd/syncrepl.c | 10 ++++++++++ 3 files changed, 12 insertions(+) diff --git a/servers/slapd/config.c b/servers/slapd/config.c index 8695fcd11c..4dd2032b81 100644 --- a/servers/slapd/config.c +++ b/servers/slapd/config.c @@ -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 ); diff --git a/servers/slapd/slap.h b/servers/slapd/slap.h index 568cdd2334..799a5b7d8a 100644 --- a/servers/slapd/slap.h +++ b/servers/slapd/slap.h @@ -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 ); diff --git a/servers/slapd/syncrepl.c b/servers/slapd/syncrepl.c index 7794fda426..f9da2a59c5 100644 --- a/servers/slapd/syncrepl.c +++ b/servers/slapd/syncrepl.c @@ -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 ); } -- 2.39.5