From 3e8c2a470941365e72073870513e56e085aeb96d Mon Sep 17 00:00:00 2001 From: Thierry bordaz (tbordaz) Date: Apr 29 2013 13:19:15 +0000 Subject: Ticket 47325 - Crash at shutdown on a replica aggrement Bug Description: This is a followup of the ticket https://fedorahosted.org/389/ticket/618 The RA thread are waited by the main daemon at shutdown. The problem is that the RA thread are not created with the right flag so they are not joinable. Fix Description: Use the correct creation flag PR_JOINABLE_THREAD In addition this fix introduce a bind timeout for the RA. It will take the one defined in the protocol (10 min per default). Ticket: https://fedorahosted.org/389/ticket/47325 Reviewed by: Mark Reynolds (thank you Mark !) Platforms tested: Fedora 17 Flag Day: no Doc impact: no --- diff --git a/ldap/servers/plugins/replication/repl5_connection.c b/ldap/servers/plugins/replication/repl5_connection.c index b8b542e..668abda 100644 --- a/ldap/servers/plugins/replication/repl5_connection.c +++ b/ldap/servers/plugins/replication/repl5_connection.c @@ -1782,7 +1782,7 @@ bind_and_check_pwp(Repl_Connection *conn, char * binddn, char *password) const char *mech = bind_method_to_mech(conn->bindmethod); rc = slapi_ldap_bind(conn->ld, binddn, password, mech, NULL, - &ctrls, NULL, NULL); + &ctrls, &conn->timeout, NULL); if ( rc == LDAP_SUCCESS ) { diff --git a/ldap/servers/plugins/replication/repl5_protocol.c b/ldap/servers/plugins/replication/repl5_protocol.c index 76e018a..8373ba6 100644 --- a/ldap/servers/plugins/replication/repl5_protocol.c +++ b/ldap/servers/plugins/replication/repl5_protocol.c @@ -369,9 +369,9 @@ prot_start(Repl_Protocol *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 ); + PR_PRIORITY_NORMAL, PR_GLOBAL_THREAD, PR_JOINABLE_THREAD, 524288L ); #else - PR_PRIORITY_NORMAL, PR_GLOBAL_THREAD, PR_UNJOINABLE_THREAD, SLAPD_DEFAULT_THREAD_STACKSIZE); + PR_PRIORITY_NORMAL, PR_GLOBAL_THREAD, PR_JOINABLE_THREAD, SLAPD_DEFAULT_THREAD_STACKSIZE); #endif if (rp->agmt_thread == NULL) { diff --git a/ldap/servers/slapd/ldaputil.c b/ldap/servers/slapd/ldaputil.c index 3ca1139..5ac2fdd 100644 --- a/ldap/servers/slapd/ldaputil.c +++ b/ldap/servers/slapd/ldaputil.c @@ -1126,7 +1126,19 @@ slapi_ldap_bind( if (msgidp) { /* let caller process result */ *msgidp = mymsgid; } else { /* process results */ - rc = ldap_result(ld, mymsgid, LDAP_MSG_ALL, timeout, &result); + struct timeval default_timeout, *bind_timeout; + + if ((timeout == NULL) || ((timeout->tv_sec == 0) && (timeout->tv_usec == 0))) { + /* Let's wait 1 min max to bind */ + default_timeout.tv_sec = 60; + default_timeout.tv_usec = 0; + + bind_timeout = &default_timeout; + } else { + /* take the one provided by the caller. It should be the one defined in the protocol */ + bind_timeout = timeout; + } + rc = ldap_result(ld, mymsgid, LDAP_MSG_ALL, bind_timeout, &result); if (-1 == rc) { /* error */ rc = slapi_ldap_get_lderrno(ld, NULL, NULL); slapi_log_error(SLAPI_LOG_FATAL, "slapi_ldap_bind", @@ -1141,8 +1153,8 @@ slapi_ldap_bind( slapi_log_error(SLAPI_LOG_FATAL, "slapi_ldap_bind", "Error: timeout after [%ld.%ld] seconds reading " "bind response for [%s] authentication mechanism [%s]\n", - timeout ? timeout->tv_sec : 0, - timeout ? timeout->tv_usec : 0, + bind_timeout ? bind_timeout->tv_sec : 0, + bind_timeout ? bind_timeout->tv_usec : 0, bindid ? bindid : "(anon)", mech ? mech : "SIMPLE"); goto done;