Commit b032b5ea authored by Quanah Gibson-Mount's avatar Quanah Gibson-Mount
Browse files

ITS#6672

parent 86b38d13
......@@ -47,6 +47,7 @@ OpenLDAP 2.4.24 Engineering
Fixed contrib/nssov multi platform support (ITS#6604)
Build Environment
Added support for [unsigned] long long (ITS#6622)
Fixed libldap mutex code - cleanup (ITS#6672)
Fixed slapd-tester EOF handling (ITS#6723)
Fixed slapd-tesster filter initialization (ITS#6735)
Removed antiquated SunOS LWP support (ITS#6669)
......
......@@ -71,18 +71,14 @@ ldap_abandon_ext(
Debug( LDAP_DEBUG_TRACE, "ldap_abandon_ext %d\n", msgid, 0, 0 );
/* check client controls */
#ifdef LDAP_R_COMPILE
ldap_pvt_thread_mutex_lock( &ld->ld_req_mutex );
#endif
LDAP_MUTEX_LOCK( &ld->ld_req_mutex );
rc = ldap_int_client_controls( ld, cctrls );
if ( rc == LDAP_SUCCESS ) {
rc = do_abandon( ld, msgid, msgid, sctrls, 1 );
}
#ifdef LDAP_R_COMPILE
ldap_pvt_thread_mutex_unlock( &ld->ld_req_mutex );
#endif
LDAP_MUTEX_UNLOCK( &ld->ld_req_mutex );
return rc;
}
......@@ -115,16 +111,9 @@ ldap_pvt_discard(
{
int rc;
#ifdef LDAP_R_COMPILE
ldap_pvt_thread_mutex_lock( &ld->ld_req_mutex );
#endif
LDAP_MUTEX_LOCK( &ld->ld_req_mutex );
rc = do_abandon( ld, msgid, msgid, NULL, 0 );
#ifdef LDAP_R_COMPILE
ldap_pvt_thread_mutex_unlock( &ld->ld_req_mutex );
#endif
LDAP_MUTEX_UNLOCK( &ld->ld_req_mutex );
return rc;
}
......@@ -180,13 +169,9 @@ start_again:;
/* ldap_msgdelete locks the res_mutex. Give up the req_mutex
* while we're in there.
*/
#ifdef LDAP_R_COMPILE
ldap_pvt_thread_mutex_unlock( &ld->ld_req_mutex );
#endif
LDAP_MUTEX_UNLOCK( &ld->ld_req_mutex );
err = ldap_msgdelete( ld, msgid );
#ifdef LDAP_R_COMPILE
ldap_pvt_thread_mutex_lock( &ld->ld_req_mutex );
#endif
LDAP_MUTEX_LOCK( &ld->ld_req_mutex );
if ( err == 0 ) {
ld->ld_errno = LDAP_SUCCESS;
return LDAP_SUCCESS;
......@@ -302,12 +287,10 @@ start_again:;
}
}
#ifdef LDAP_R_COMPILE
/* ld_abandoned is actually protected by the ld_res_mutex;
* give up the ld_req_mutex and get the other */
ldap_pvt_thread_mutex_unlock( &ld->ld_req_mutex );
ldap_pvt_thread_mutex_lock( &ld->ld_res_mutex );
#endif
LDAP_MUTEX_UNLOCK( &ld->ld_req_mutex );
LDAP_MUTEX_LOCK( &ld->ld_res_mutex );
/* use bisection */
i = 0;
......@@ -321,10 +304,8 @@ start_again:;
ld->ld_errno = LDAP_SUCCESS;
}
#ifdef LDAP_R_COMPILE
ldap_pvt_thread_mutex_unlock( &ld->ld_res_mutex );
ldap_pvt_thread_mutex_lock( &ld->ld_req_mutex );
#endif
LDAP_MUTEX_UNLOCK( &ld->ld_res_mutex );
LDAP_MUTEX_LOCK( &ld->ld_req_mutex );
return( ld->ld_errno );
}
......
......@@ -410,9 +410,7 @@ ldap_int_sasl_bind(
}
rc = 0;
#ifdef LDAP_R_COMPILE
ldap_pvt_thread_mutex_lock( &ld->ld_req_mutex );
#endif
LDAP_MUTEX_LOCK( &ld->ld_req_mutex );
ber_sockbuf_ctrl( ld->ld_sb, LBER_SB_OPT_GET_FD, &sd );
if ( sd == AC_SOCKET_INVALID ) {
......@@ -430,9 +428,7 @@ ldap_int_sasl_bind(
}
}
}
#ifdef LDAP_R_COMPILE
ldap_pvt_thread_mutex_unlock( &ld->ld_req_mutex );
#endif
LDAP_MUTEX_UNLOCK( &ld->ld_req_mutex );
if( rc != 0 ) return ld->ld_errno;
oldctx = ld->ld_defconn->lconn_sasl_authctx;
......
......@@ -202,9 +202,7 @@ int ldap_domain2hostlist(
}
sprintf(request, "_ldap._tcp.%s", domain);
#ifdef LDAP_R_COMPILE
ldap_pvt_thread_mutex_lock(&ldap_int_resolv_mutex);
#endif
LDAP_MUTEX_LOCK(&ldap_int_resolv_mutex);
rc = LDAP_UNAVAILABLE;
#ifdef NS_HFIXEDSZ
......@@ -305,9 +303,7 @@ add_size:;
*list = hostlist;
out:
#ifdef LDAP_R_COMPILE
ldap_pvt_thread_mutex_unlock(&ldap_int_resolv_mutex);
#endif
LDAP_MUTEX_UNLOCK(&ldap_int_resolv_mutex);
if (request != NULL) {
LDAP_FREE(request);
......
......@@ -260,9 +260,7 @@ ldap_parse_result(
if(referralsp != NULL) *referralsp = NULL;
if(serverctrls != NULL) *serverctrls = NULL;
#ifdef LDAP_R_COMPILE
ldap_pvt_thread_mutex_lock( &ld->ld_res_mutex );
#endif
LDAP_MUTEX_LOCK( &ld->ld_res_mutex );
/* Find the result, last msg in chain... */
lm = r->lm_chain_tail;
/* FIXME: either this is not possible (assert?)
......@@ -282,9 +280,7 @@ ldap_parse_result(
if( lm == NULL ) {
errcode = ld->ld_errno = LDAP_NO_RESULTS_RETURNED;
#ifdef LDAP_R_COMPILE
ldap_pvt_thread_mutex_unlock( &ld->ld_res_mutex );
#endif
LDAP_MUTEX_UNLOCK( &ld->ld_res_mutex );
goto done;
}
......@@ -390,10 +386,7 @@ ldap_parse_result(
*referralsp = ldap_value_dup( ld->ld_referrals );
}
}
#ifdef LDAP_R_COMPILE
ldap_pvt_thread_mutex_unlock( &ld->ld_res_mutex );
#endif
LDAP_MUTEX_UNLOCK( &ld->ld_res_mutex );
done:
if ( freeit ) {
......
......@@ -435,11 +435,22 @@ LDAP_V( ldap_pvt_thread_mutex_t ) ldap_int_gssapi_mutex;
#endif
#endif
#ifdef LDAP_R_COMPILE
#define LDAP_MUTEX_LOCK(mutex) ldap_pvt_thread_mutex_lock( mutex )
#define LDAP_MUTEX_UNLOCK(mutex) ldap_pvt_thread_mutex_unlock( mutex )
#define LDAP_ASSERT_MUTEX_OWNER(mutex) \
LDAP_PVT_THREAD_ASSERT_MUTEX_OWNER(mutex)
#else
#define LDAP_MUTEX_LOCK(mutex)
#define LDAP_MUTEX_UNLOCK(mutex)
#define LDAP_ASSERT_MUTEX_OWNER(mutex)
#endif
#ifdef LDAP_R_COMPILE
#define LDAP_NEXT_MSGID(ld, id) \
ldap_pvt_thread_mutex_lock( &(ld)->ld_req_mutex ); \
LDAP_MUTEX_LOCK( &(ld)->ld_req_mutex ); \
id = ++(ld)->ld_msgid; \
ldap_pvt_thread_mutex_unlock( &(ld)->ld_req_mutex )
LDAP_MUTEX_UNLOCK( &(ld)->ld_req_mutex )
#else
#define LDAP_NEXT_MSGID(ld, id) id = ++(ld)->ld_msgid
#endif
......
......@@ -592,16 +592,12 @@ ldap_connect_to_host(LDAP *ld, Sockbuf *sb,
hints.ai_socktype = socktype;
snprintf(serv, sizeof serv, "%d", port );
#ifdef LDAP_R_COMPILE
/* most getaddrinfo(3) use non-threadsafe resolver libraries */
ldap_pvt_thread_mutex_lock(&ldap_int_resolv_mutex);
#endif
LDAP_MUTEX_LOCK(&ldap_int_resolv_mutex);
err = getaddrinfo( host, serv, &hints, &res );
#ifdef LDAP_R_COMPILE
ldap_pvt_thread_mutex_unlock(&ldap_int_resolv_mutex);
#endif
LDAP_MUTEX_UNLOCK(&ldap_int_resolv_mutex);
if ( err != 0 ) {
osip_debug(ld, "ldap_connect_to_host: getaddrinfo failed: %s\n",
......
......@@ -98,17 +98,13 @@ ldap_send_initial_request(
Debug( LDAP_DEBUG_TRACE, "ldap_send_initial_request\n", 0, 0, 0 );
#ifdef LDAP_R_COMPILE
ldap_pvt_thread_mutex_lock( &ld->ld_req_mutex );
#endif
LDAP_MUTEX_LOCK( &ld->ld_req_mutex );
if ( ber_sockbuf_ctrl( ld->ld_sb, LBER_SB_OPT_GET_FD, NULL ) == -1 ) {
/* not connected yet */
rc = ldap_open_defconn( ld );
}
#ifdef LDAP_R_COMPILE
ldap_pvt_thread_mutex_unlock( &ld->ld_req_mutex );
#endif
LDAP_MUTEX_UNLOCK( &ld->ld_req_mutex );
if( rc < 0 ) {
ber_free( ber, 1 );
return( -1 );
......@@ -134,14 +130,10 @@ ldap_send_initial_request(
}
}
#endif
#ifdef LDAP_R_COMPILE
ldap_pvt_thread_mutex_lock( &ld->ld_req_mutex );
#endif
LDAP_MUTEX_LOCK( &ld->ld_req_mutex );
rc = ldap_send_server_request( ld, ber, msgid, NULL,
NULL, NULL, NULL );
#ifdef LDAP_R_COMPILE
ldap_pvt_thread_mutex_unlock( &ld->ld_req_mutex );
#endif
LDAP_MUTEX_UNLOCK( &ld->ld_req_mutex );
return(rc);
}
......@@ -453,20 +445,14 @@ ldap_new_connection( LDAP *ld, LDAPURLDesc **srvlist, int use_ldsb,
}
lc->lconn_status = async ? LDAP_CONNST_CONNECTING : LDAP_CONNST_CONNECTED;
#ifdef LDAP_R_COMPILE
ldap_pvt_thread_mutex_lock( &ld->ld_conn_mutex );
#endif
LDAP_MUTEX_LOCK( &ld->ld_conn_mutex );
lc->lconn_next = ld->ld_conns;
ld->ld_conns = lc;
#ifdef LDAP_R_COMPILE
ldap_pvt_thread_mutex_unlock( &ld->ld_conn_mutex );
#endif
LDAP_MUTEX_UNLOCK( &ld->ld_conn_mutex );
if ( connect ) {
#ifdef LDAP_R_COMPILE
LDAP_PVT_THREAD_ASSERT_MUTEX_OWNER( &ld->ld_req_mutex );
LDAP_PVT_THREAD_ASSERT_MUTEX_OWNER( &ld->ld_res_mutex );
#endif
LDAP_ASSERT_MUTEX_OWNER( &ld->ld_req_mutex );
LDAP_ASSERT_MUTEX_OWNER( &ld->ld_res_mutex );
#ifdef HAVE_TLS
if ( lc->lconn_server->lud_exts ) {
......@@ -478,15 +464,11 @@ ldap_new_connection( LDAP *ld, LDAPURLDesc **srvlist, int use_ldsb,
++lc->lconn_refcnt; /* avoid premature free */
ld->ld_defconn = lc;
#ifdef LDAP_R_COMPILE
ldap_pvt_thread_mutex_unlock( &ld->ld_req_mutex );
ldap_pvt_thread_mutex_unlock( &ld->ld_res_mutex );
#endif
LDAP_MUTEX_UNLOCK( &ld->ld_req_mutex );
LDAP_MUTEX_UNLOCK( &ld->ld_res_mutex );
rc = ldap_start_tls_s( ld, NULL, NULL );
#ifdef LDAP_R_COMPILE
ldap_pvt_thread_mutex_lock( &ld->ld_res_mutex );
ldap_pvt_thread_mutex_lock( &ld->ld_req_mutex );
#endif
LDAP_MUTEX_LOCK( &ld->ld_res_mutex );
LDAP_MUTEX_LOCK( &ld->ld_req_mutex );
ld->ld_defconn = savedefconn;
--lc->lconn_refcnt;
......@@ -503,10 +485,8 @@ ldap_new_connection( LDAP *ld, LDAPURLDesc **srvlist, int use_ldsb,
int err = 0;
LDAPConn *savedefconn;
#ifdef LDAP_R_COMPILE
LDAP_PVT_THREAD_ASSERT_MUTEX_OWNER( &ld->ld_req_mutex );
LDAP_PVT_THREAD_ASSERT_MUTEX_OWNER( &ld->ld_res_mutex );
#endif
LDAP_ASSERT_MUTEX_OWNER( &ld->ld_req_mutex );
LDAP_ASSERT_MUTEX_OWNER( &ld->ld_res_mutex );
/* Set flag to prevent additional referrals
* from being processed on this
......@@ -527,17 +507,13 @@ ldap_new_connection( LDAP *ld, LDAPURLDesc **srvlist, int use_ldsb,
ld->ld_defconn = lc;
Debug( LDAP_DEBUG_TRACE, "Call application rebind_proc\n", 0, 0, 0);
#ifdef LDAP_R_COMPILE
ldap_pvt_thread_mutex_unlock( &ld->ld_req_mutex );
ldap_pvt_thread_mutex_unlock( &ld->ld_res_mutex );
#endif
LDAP_MUTEX_UNLOCK( &ld->ld_req_mutex );
LDAP_MUTEX_UNLOCK( &ld->ld_res_mutex );
err = (*ld->ld_rebind_proc)( ld,
bind->ri_url, bind->ri_request, bind->ri_msgid,
ld->ld_rebind_params );
#ifdef LDAP_R_COMPILE
ldap_pvt_thread_mutex_lock( &ld->ld_res_mutex );
ldap_pvt_thread_mutex_lock( &ld->ld_req_mutex );
#endif
LDAP_MUTEX_LOCK( &ld->ld_res_mutex );
LDAP_MUTEX_LOCK( &ld->ld_req_mutex );
ld->ld_defconn = savedefconn;
--lc->lconn_refcnt;
......@@ -562,10 +538,8 @@ ldap_new_connection( LDAP *ld, LDAPURLDesc **srvlist, int use_ldsb,
"anonymous rebind via ldap_sasl_bind(\"\")\n",
0, 0, 0);
#ifdef LDAP_R_COMPILE
ldap_pvt_thread_mutex_unlock( &ld->ld_req_mutex );
ldap_pvt_thread_mutex_unlock( &ld->ld_res_mutex );
#endif
LDAP_MUTEX_UNLOCK( &ld->ld_req_mutex );
LDAP_MUTEX_UNLOCK( &ld->ld_res_mutex );
rc = ldap_sasl_bind( ld, "", LDAP_SASL_SIMPLE, &passwd,
NULL, NULL, &msgid );
if ( rc != LDAP_SUCCESS ) {
......@@ -609,10 +583,8 @@ ldap_new_connection( LDAP *ld, LDAPURLDesc **srvlist, int use_ldsb,
}
}
}
#ifdef LDAP_R_COMPILE
ldap_pvt_thread_mutex_lock( &ld->ld_res_mutex );
ldap_pvt_thread_mutex_lock( &ld->ld_req_mutex );
#endif
LDAP_MUTEX_LOCK( &ld->ld_res_mutex );
LDAP_MUTEX_LOCK( &ld->ld_req_mutex );
ld->ld_defconn = savedefconn;
--lc->lconn_refcnt;
......@@ -641,9 +613,7 @@ find_connection( LDAP *ld, LDAPURLDesc *srv, int any )
int lcu_port, lsu_port;
int found = 0;
#ifdef LDAP_R_COMPILE
ldap_pvt_thread_mutex_lock( &ld->ld_conn_mutex );
#endif
LDAP_MUTEX_LOCK( &ld->ld_conn_mutex );
for ( lc = ld->ld_conns; lc != NULL; lc = lc->lconn_next ) {
lcu = lc->lconn_server;
lcu_port = ldap_pvt_url_scheme_port( lcu->lud_scheme,
......@@ -667,9 +637,7 @@ find_connection( LDAP *ld, LDAPURLDesc *srv, int any )
if ( found )
break;
}
#ifdef LDAP_R_COMPILE
ldap_pvt_thread_mutex_unlock( &ld->ld_conn_mutex );
#endif
LDAP_MUTEX_UNLOCK( &ld->ld_conn_mutex );
return lc;
}
......@@ -697,9 +665,7 @@ ldap_free_connection( LDAP *ld, LDAPConn *lc, int force, int unbind )
if ( force || --lc->lconn_refcnt <= 0 ) {
/* remove from connections list first */
#ifdef LDAP_R_COMPILE
ldap_pvt_thread_mutex_lock( &ld->ld_conn_mutex );
#endif
LDAP_MUTEX_LOCK( &ld->ld_conn_mutex );
for ( prevlc = NULL, tmplc = ld->ld_conns;
tmplc != NULL;
......@@ -718,9 +684,7 @@ ldap_free_connection( LDAP *ld, LDAPConn *lc, int force, int unbind )
}
prevlc = tmplc;
}
#ifdef LDAP_R_COMPILE
ldap_pvt_thread_mutex_unlock( &ld->ld_conn_mutex );
#endif
LDAP_MUTEX_UNLOCK( &ld->ld_conn_mutex );
/* process connection callbacks */
{
......@@ -960,9 +924,7 @@ ldap_free_request_int( LDAP *ld, LDAPRequest *lr )
void
ldap_free_request( LDAP *ld, LDAPRequest *lr )
{
#ifdef LDAP_R_COMPILE
LDAP_PVT_THREAD_ASSERT_MUTEX_OWNER( &ld->ld_req_mutex );
#endif
LDAP_ASSERT_MUTEX_OWNER( &ld->ld_req_mutex );
Debug( LDAP_DEBUG_TRACE, "ldap_free_request (origid %d, msgid %d)\n",
lr->lr_origid, lr->lr_msgid, 0 );
......@@ -1222,14 +1184,10 @@ ldap_chase_v3referrals( LDAP *ld, LDAPRequest *lr, char **refs, int sref, char *
/* Send the new request to the server - may require a bind */
rinfo.ri_msgid = origreq->lr_origid;
rinfo.ri_url = refarray[i];
#ifdef LDAP_R_COMPILE
ldap_pvt_thread_mutex_lock( &ld->ld_req_mutex );
#endif
LDAP_MUTEX_LOCK( &ld->ld_req_mutex );
rc = ldap_send_server_request( ld, ber, id,
origreq, &srv, NULL, &rinfo );
#ifdef LDAP_R_COMPILE
ldap_pvt_thread_mutex_unlock( &ld->ld_req_mutex );
#endif
LDAP_MUTEX_UNLOCK( &ld->ld_req_mutex );
if ( rc < 0 ) {
/* Failure, try next referral in the list */
Debug( LDAP_DEBUG_ANY, "Unable to chase referral \"%s\" (%d: %s)\n",
......@@ -1409,14 +1367,10 @@ ldap_chase_referrals( LDAP *ld,
rinfo.ri_msgid = origreq->lr_origid;
#ifdef LDAP_R_COMPILE
ldap_pvt_thread_mutex_lock( &ld->ld_req_mutex );
#endif
LDAP_MUTEX_LOCK( &ld->ld_req_mutex );
rc = ldap_send_server_request( ld, ber, id,
lr, &srv, NULL, &rinfo );
#ifdef LDAP_R_COMPILE
ldap_pvt_thread_mutex_unlock( &ld->ld_req_mutex );
#endif
LDAP_MUTEX_UNLOCK( &ld->ld_req_mutex );
LDAP_FREE( rinfo.ri_url );
......@@ -1612,9 +1566,7 @@ ldap_find_request_by_msgid( LDAP *ld, ber_int_t msgid )
{
LDAPRequest *lr;
#ifdef LDAP_R_COMPILE
ldap_pvt_thread_mutex_lock( &ld->ld_req_mutex );
#endif
LDAP_MUTEX_LOCK( &ld->ld_req_mutex );
for ( lr = ld->ld_requests; lr != NULL; lr = lr->lr_next ) {
if ( lr->lr_status == LDAP_REQST_COMPLETED ) {
continue; /* Skip completed requests */
......@@ -1624,9 +1576,7 @@ ldap_find_request_by_msgid( LDAP *ld, ber_int_t msgid )
break;
}
}
#ifdef LDAP_R_COMPILE
ldap_pvt_thread_mutex_unlock( &ld->ld_req_mutex );
#endif
LDAP_MUTEX_UNLOCK( &ld->ld_req_mutex );
return( lr );
}
......@@ -1636,9 +1586,7 @@ ldap_return_request( LDAP *ld, LDAPRequest *lrx, int freeit )
{
LDAPRequest *lr;
#ifdef LDAP_R_COMPILE
ldap_pvt_thread_mutex_lock( &ld->ld_req_mutex );
#endif
LDAP_MUTEX_LOCK( &ld->ld_req_mutex );
for ( lr = ld->ld_requests; lr != NULL; lr = lr->lr_next ) {
if ( lr == lrx ) {
if ( lr->lr_refcnt > 0 ) {
......@@ -1659,7 +1607,5 @@ ldap_return_request( LDAP *ld, LDAPRequest *lrx, int freeit )
} else if ( freeit ) {
ldap_free_request( ld, lrx );
}
#ifdef LDAP_R_COMPILE
ldap_pvt_thread_mutex_unlock( &ld->ld_req_mutex );
#endif
LDAP_MUTEX_UNLOCK( &ld->ld_req_mutex );
}
......@@ -113,15 +113,9 @@ ldap_result(
Debug( LDAP_DEBUG_TRACE, "ldap_result ld %p msgid %d\n", (void *)ld, msgid, 0 );
#ifdef LDAP_R_COMPILE
ldap_pvt_thread_mutex_lock( &ld->ld_res_mutex );
#endif
LDAP_MUTEX_LOCK( &ld->ld_res_mutex );
rc = wait4msg( ld, msgid, all, timeout, result );
#ifdef LDAP_R_COMPILE
ldap_pvt_thread_mutex_unlock( &ld->ld_res_mutex );
#endif
LDAP_MUTEX_UNLOCK( &ld->ld_res_mutex );
return rc;
}
......@@ -142,9 +136,7 @@ chkResponseList(
* wait until it arrives or timeout occurs.
*/
#ifdef LDAP_R_COMPILE
LDAP_PVT_THREAD_ASSERT_MUTEX_OWNER( &ld->ld_res_mutex );
#endif
LDAP_ASSERT_MUTEX_OWNER( &ld->ld_res_mutex );
Debug( LDAP_DEBUG_TRACE,
"ldap_chkResponseList ld %p msgid %d all %d\n",
......@@ -257,9 +249,7 @@ wait4msg(
assert( ld != NULL );
assert( result != NULL );
#ifdef LDAP_R_COMPILE
LDAP_PVT_THREAD_ASSERT_MUTEX_OWNER( &ld->ld_res_mutex );
#endif
LDAP_ASSERT_MUTEX_OWNER( &ld->ld_res_mutex );
if ( timeout == NULL && ld->ld_options.ldo_tm_api.tv_sec >= 0 ) {
tv = ld->ld_options.ldo_tm_api;
......@@ -294,18 +284,12 @@ wait4msg(
if ( ldap_debug & LDAP_DEBUG_TRACE ) {
Debug( LDAP_DEBUG_TRACE, "wait4msg continue ld %p msgid %d all %d\n",
(void *)ld, msgid, all );
#ifdef LDAP_R_COMPILE
ldap_pvt_thread_mutex_lock( &ld->ld_conn_mutex );
#endif
LDAP_MUTEX_LOCK( &ld->ld_conn_mutex );
ldap_dump_connection( ld, ld->ld_conns, 1 );
#ifdef LDAP_R_COMPILE
ldap_pvt_thread_mutex_unlock( &ld->ld_conn_mutex );
ldap_pvt_thread_mutex_lock( &ld->ld_req_mutex );
#endif
LDAP_MUTEX_UNLOCK( &ld->ld_conn_mutex );
LDAP_MUTEX_LOCK( &ld->ld_req_mutex );
ldap_dump_requests_and_responses( ld );
#ifdef LDAP_R_COMPILE
ldap_pvt_thread_mutex_unlock( &ld->ld_req_mutex );
#endif
LDAP_MUTEX_UNLOCK( &ld->ld_req_mutex );
}
#endif /* LDAP_DEBUG */
......@@ -315,9 +299,7 @@ wait4msg(
} else {
int lc_ready = 0;
#ifdef LDAP_R_COMPILE
ldap_pvt_thread_mutex_lock( &ld->ld_conn_mutex );
#endif
LDAP_MUTEX_LOCK( &ld->ld_conn_mutex );
for ( lc = ld->ld_conns; lc != NULL; lc = lc->lconn_next ) {
if ( ber_sockbuf_ctrl( lc->lconn_sb,
LBER_SB_OPT_DATA_READY, NULL ) )
......@@ -326,9 +308,7 @@ wait4msg(
break;
}
}
#ifdef LDAP_R_COMPILE
ldap_pvt_thread_mutex_unlock( &ld->ld_conn_mutex );
#endif
LDAP_MUTEX_UNLOCK( &ld->ld_conn_mutex );
if ( !lc_ready ) {
int err;
......@@ -361,9 +341,7 @@ wait4msg(
if ( lc_ready ) {
LDAPConn *lnext;
rc = LDAP_MSG_X_KEEP_LOOKING;
#ifdef LDAP_R_COMPILE
ldap_pvt_thread_mutex_lock( &ld->ld_req_mutex );
#endif
LDAP_MUTEX_LOCK( &ld->ld_req_mutex );
if ( ld->ld_requests &&
ld->ld_requests->lr_status == LDAP_REQST_WRITING &&
ldap_is_write_ready( ld,
......@@ -371,10 +349,8 @@ wait4msg(
{
ldap_int_flush_request( ld, ld->ld_requests );
}
#ifdef LDAP_R_COMPILE
ldap_pvt_thread_mutex_unlock( &ld->ld_req_mutex );
ldap_pvt_thread_mutex_lock( &ld->ld_conn_mutex );
#endif
LDAP_MUTEX_UNLOCK( &ld->ld_req_mutex );
LDAP_MUTEX_LOCK( &ld->ld_conn_mutex );
for ( lc = ld->ld_conns;
rc == LDAP_MSG_X_KEEP_LOOKING && lc != NULL;
lc = lnext )
......@@ -384,34 +360,24 @@ wait4msg(
{
/* Don't let it get freed out from under us */
++lc->lconn_refcnt;
#ifdef LDAP_R_COMPILE
ldap_pvt_thread_mutex_unlock( &ld->ld_conn_mutex );
#endif
LDAP_MUTEX_UNLOCK( &ld->ld_conn_mutex );
rc = try_read1msg( ld, msgid, all, lc, result );
lnext = lc->lconn_next;
/* Only take locks if we're really freeing */
if ( lc->lconn_refcnt <= 1 ) {
#ifdef LDAP_R_COMPILE
ldap_pvt_thread_mutex_lock( &ld->ld_req_mutex );
#endif
LDAP_MUTEX_LOCK( &ld->ld_req_mutex );
ldap_free_connection( ld, lc, 0, 1 );
#ifdef LDAP_R_COMPILE
ldap_pvt_thread_mutex_unlock( &ld->ld_req_mutex );
#endif
LDAP_MUTEX_UNLOCK( &ld->ld_req_mutex );
} else {
--lc->lconn_refcnt;
}
#ifdef LDAP_R_COMPILE
ldap_pvt_thread_mutex_lock( &ld->ld_conn_mutex );
#endif
LDAP_MUTEX_LOCK( &ld->ld_conn_mutex );
} else {
lnext = lc->lconn_next;
}
}
#ifdef LDAP_R_COMPILE
ldap_pvt_thread_mutex_unlock( &ld->ld_conn_mutex );
#endif
LDAP_MUTEX_UNLOCK( &ld->ld_conn_mutex );
}
}
......@@ -494,9 +460,7 @@ try_read1msg(
assert( ld != NULL );