diff options
Diffstat (limited to 'ldap/servers/plugins/replication/repl5_protocol.c')
-rw-r--r-- | ldap/servers/plugins/replication/repl5_protocol.c | 49 |
1 files changed, 15 insertions, 34 deletions
diff --git a/ldap/servers/plugins/replication/repl5_protocol.c b/ldap/servers/plugins/replication/repl5_protocol.c index e909ed45..927c450a 100644 --- a/ldap/servers/plugins/replication/repl5_protocol.c +++ b/ldap/servers/plugins/replication/repl5_protocol.c @@ -77,7 +77,6 @@ typedef struct repl_protocol /* States */ #define STATE_FINISHED 503 -#define STATE_DONE 504 #define STATE_BAD_STATE_SHOULD_NEVER_HAPPEN 599 /* Forward declarations */ @@ -174,10 +173,8 @@ prot_get_agreement(Repl_Protocol *rp) -/* - */ void -prot_free(Repl_Protocol **rpp, int wait_for_done) +prot_free(Repl_Protocol **rpp) { Repl_Protocol *rp = NULL; PRIntervalTime interval; @@ -185,30 +182,6 @@ prot_free(Repl_Protocol **rpp, int wait_for_done) if (rpp == NULL || *rpp == NULL) return; rp = *rpp; - /* - * This function has to wait until prot_thread_main exits if - * prot_start is successfully called and prot_thread_main is - * running. Otherwise, we may free Repl_Protocol while it's - * being used. - * - * This function is supposed to be called when the protocol is - * stopped either after prot_stop is called or when protocol - * hasn't been started. - * - * The latter case: prot_free is called with wait_for_done = 0. - * The former case: prot_free is called with wait_for_done = 1. - * prot_stop had set STATE_FINISHED to next_state and stopped - * the current activity. But depending upon the threads' - * scheduling, prot_thread_main may not have gotten out of the - * while loop at this moment. To make sure prot_thread_main - * finished referring Repl_Protocol, we wait for the state set - * to STATE_DONE. - */ - interval = PR_MillisecondsToInterval(1000); - while (wait_for_done && STATE_DONE != rp->state) - { - DS_Sleep(interval); - } PR_Lock(rp->lock); if (NULL != rp->prp_incremental) @@ -247,7 +220,7 @@ prot_delete(Repl_Protocol **rpp) if (NULL != rp) { prot_stop(rp); - prot_free(rpp, 1); + prot_free(rpp); } } @@ -319,11 +292,13 @@ prot_thread_main(void *arg) { Repl_Protocol *rp = (Repl_Protocol *)arg; int done; + Repl_Agmt *agmt = NULL; PR_ASSERT(NULL != rp); - if (rp->agmt) { - set_thread_private_agmtname (agmt_get_long_name(rp->agmt)); + agmt = rp->agmt; + if (agmt) { + set_thread_private_agmtname (agmt_get_long_name(agmt)); } done = 0; @@ -355,7 +330,7 @@ prot_thread_main(void *arg) dev_debug("prot_thread_main(STATE_PERFORMING_TOTAL_UPDATE): end"); /* update the agreement entry to notify clients that replica initialization is completed. */ - agmt_replica_init_done (rp->agmt); + agmt_replica_init_done (agmt); break; case STATE_FINISHED: @@ -363,9 +338,15 @@ prot_thread_main(void *arg) done = 1; break; } - rp->state = rp->next_state; + if (agmt_has_protocol(agmt)) + { + rp->state = rp->next_state; + } + else + { + done = 1; + } } - rp->state = STATE_DONE; } |