ldap/servers/plugins/replication/repl5_protocol.c | 13 ++++++++++---
1 file changed, 10 insertions(+), 3 deletions(-)
New commits:
commit 957bea3e270e3af820b1fe500017acde90e4356d
Author: Thierry bordaz (tbordaz) <tbordaz(a)redhat.com>
Date: Thu Mar 21 11:11:34 2013 +0100
Ticket 618 - Crash at shutdown while stopping replica agreements
Bug Description:
During shutdown, the replica agreement thread can be long to detect the shutdown.
If replica agreements fails to detect shutdown before timeout (default is 120s),
the shutdown continue and deletes replica agreement structure.
Fix Description:
The fix consist to make the main thread wait for the RA thread.
https://fedorahosted.org/389/ticket/618
Reviewed by: Rich Megginson (thanks for the review Rich)
Platforms tested: fedora 18
Flag Day: no
Doc impact: no
diff --git a/ldap/servers/plugins/replication/repl5_protocol.c
b/ldap/servers/plugins/replication/repl5_protocol.c
index 250ce48..d9744fc 100644
--- a/ldap/servers/plugins/replication/repl5_protocol.c
+++ b/ldap/servers/plugins/replication/repl5_protocol.c
@@ -72,6 +72,7 @@ typedef struct repl_protocol
int state;
int next_state;
PRUint64 protocol_timeout;
+ PRThread *agmt_thread;
PRLock *lock;
} repl_protocol;
@@ -366,12 +367,13 @@ prot_start(Repl_Protocol *rp)
PR_ASSERT(NULL != rp);
if (NULL != rp)
{
- if (PR_CreateThread(PR_USER_THREAD, prot_thread_main, (void *)rp,
+ rp->agmt_thread = PR_CreateThread(PR_USER_THREAD, prot_thread_main,
(void *)rp,
#if defined(__hpux) && defined(__ia64)
- PR_PRIORITY_NORMAL, PR_GLOBAL_THREAD, PR_UNJOINABLE_THREAD, 524288L ) == NULL)
+ PR_PRIORITY_NORMAL, PR_GLOBAL_THREAD, PR_UNJOINABLE_THREAD, 524288L );
#else
- PR_PRIORITY_NORMAL, PR_GLOBAL_THREAD, PR_UNJOINABLE_THREAD,
SLAPD_DEFAULT_THREAD_STACKSIZE) == NULL)
+ PR_PRIORITY_NORMAL, PR_GLOBAL_THREAD, PR_UNJOINABLE_THREAD,
SLAPD_DEFAULT_THREAD_STACKSIZE);
#endif
+ if (rp->agmt_thread == NULL)
{
PRErrorCode prerr = PR_GetError();
@@ -426,6 +428,11 @@ prot_stop(Repl_Protocol *rp)
slapi_log_error(SLAPI_LOG_FATAL, repl_plugin_name, "Error: prot_stop() "
" called on NULL protocol instance.\n");
}
+
+ if (rp->agmt_thread != NULL) {
+ (void) PR_JoinThread(rp->agmt_thread);
+ rp->agmt_thread = NULL;
+ }
}
/*