From: Pierangelo Masarati Date: Thu, 11 Jun 2009 06:51:01 +0000 (+0000) Subject: don't deadlock when a TLS uri is not responding (ITS#6167) X-Git-Tag: ACLCHECK_0~501 X-Git-Url: https://git.sur5r.net/?a=commitdiff_plain;h=c39815ee2825d806567795f0215cc27558f8a2cb;p=openldap don't deadlock when a TLS uri is not responding (ITS#6167) --- diff --git a/servers/slapd/back-ldap/back-ldap.h b/servers/slapd/back-ldap/back-ldap.h index 54e55ce633..7069245701 100644 --- a/servers/slapd/back-ldap/back-ldap.h +++ b/servers/slapd/back-ldap/back-ldap.h @@ -245,6 +245,9 @@ typedef struct ldapinfo_t { * to be checked for the presence of a certain item */ BerVarray li_bvuri; ldap_pvt_thread_mutex_t li_uri_mutex; + /* hack because when TLS is used we need to lock and let + * the li_urllist_f function to know it's locked */ + int li_uri_mutex_do_not_lock; LDAP_REBIND_PROC *li_rebind_f; LDAP_URLLIST_PROC *li_urllist_f; diff --git a/servers/slapd/back-ldap/bind.c b/servers/slapd/back-ldap/bind.c index 9691f11f6d..2521b3fbf8 100644 --- a/servers/slapd/back-ldap/bind.c +++ b/servers/slapd/back-ldap/bind.c @@ -691,8 +691,11 @@ ldap_back_prepare_conn( ldapconn_t *lc, Operation *op, SlapReply *rs, ldap_back_ } ldap_pvt_thread_mutex_lock( &li->li_uri_mutex ); + assert( li->li_uri_mutex_do_not_lock == 0 ); + li->li_uri_mutex_do_not_lock = 1; rs->sr_err = ldap_back_start_tls( ld, op->o_protocol, &is_tls, li->li_uri, li->li_flags, li->li_nretries, &rs->sr_text ); + li->li_uri_mutex_do_not_lock = 0; ldap_pvt_thread_mutex_unlock( &li->li_uri_mutex ); if ( rs->sr_err != LDAP_SUCCESS ) { ldap_unbind_ext( ld, NULL, NULL ); @@ -1581,13 +1584,19 @@ ldap_back_default_urllist( *urllist = *url; *url = NULL; - ldap_pvt_thread_mutex_lock( &li->li_uri_mutex ); + if ( !li->li_uri_mutex_do_not_lock ) { + ldap_pvt_thread_mutex_lock( &li->li_uri_mutex ); + } + if ( li->li_uri ) { ch_free( li->li_uri ); } ldap_get_option( ld, LDAP_OPT_URI, (void *)&li->li_uri ); - ldap_pvt_thread_mutex_unlock( &li->li_uri_mutex ); + + if ( !li->li_uri_mutex_do_not_lock ) { + ldap_pvt_thread_mutex_unlock( &li->li_uri_mutex ); + } return LDAP_SUCCESS; }