From 614faa3911d53cd2d5ea73ab1c798e33cd47b899 Mon Sep 17 00:00:00 2001 From: Howard Chu Date: Tue, 17 Mar 2009 03:07:40 +0000 Subject: [PATCH] ITS#6011 use refcount for shared cookieState --- servers/slapd/syncrepl.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/servers/slapd/syncrepl.c b/servers/slapd/syncrepl.c index 2033100e37..6edab5dcec 100644 --- a/servers/slapd/syncrepl.c +++ b/servers/slapd/syncrepl.c @@ -41,6 +41,7 @@ typedef struct cookie_state { ldap_pvt_thread_mutex_t cs_mutex; int cs_num; int cs_age; + int cs_ref; struct berval *cs_vals; int *cs_sids; } cookie_state; @@ -1464,9 +1465,7 @@ reload: /* Do final delete cleanup */ if ( !si->si_ctype ) { - cookie_state *cs = si->si_cookieState; - syncinfo_free( si, ( !be->be_syncinfo || - be->be_syncinfo->si_cookieState != cs )); + syncinfo_free( si, 0 ); } return NULL; } @@ -3599,7 +3598,8 @@ syncinfo_free( syncinfo_t *sie, int free_all ) Debug( LDAP_DEBUG_TRACE, "syncinfo_free: %s\n", sie->si_ridtxt, 0, 0 ); - if ( free_all && sie->si_cookieState ) { + sie->si_cookieState->cs_ref--; + if ( !sie->si_cookieState->cs_ref ) { ch_free( sie->si_cookieState->cs_sids ); ber_bvarray_free( sie->si_cookieState->cs_vals ); ldap_pvt_thread_mutex_destroy( &sie->si_cookieState->cs_mutex ); @@ -4383,6 +4383,7 @@ add_syncrepl( c->be->be_syncinfo = si; } + si->si_cookieState->cs_ref++; si->si_next = NULL; -- 2.39.5