ITS#6672 mutex cleanup

This commit is contained in:
Howard Chu 2010-10-13 08:43:15 +00:00
parent 1c9853c674
commit 0b660dc9f6
11 changed files with 114 additions and 275 deletions

View File

@ -71,18 +71,14 @@ ldap_abandon_ext(
Debug( LDAP_DEBUG_TRACE, "ldap_abandon_ext %d\n", msgid, 0, 0 ); Debug( LDAP_DEBUG_TRACE, "ldap_abandon_ext %d\n", msgid, 0, 0 );
/* check client controls */ /* check client controls */
#ifdef LDAP_R_COMPILE LDAP_MUTEX_LOCK( &ld->ld_req_mutex );
ldap_pvt_thread_mutex_lock( &ld->ld_req_mutex );
#endif
rc = ldap_int_client_controls( ld, cctrls ); rc = ldap_int_client_controls( ld, cctrls );
if ( rc == LDAP_SUCCESS ) { if ( rc == LDAP_SUCCESS ) {
rc = do_abandon( ld, msgid, msgid, sctrls, 1 ); rc = do_abandon( ld, msgid, msgid, sctrls, 1 );
} }
#ifdef LDAP_R_COMPILE LDAP_MUTEX_UNLOCK( &ld->ld_req_mutex );
ldap_pvt_thread_mutex_unlock( &ld->ld_req_mutex );
#endif
return rc; return rc;
} }
@ -115,16 +111,9 @@ ldap_pvt_discard(
{ {
int rc; int rc;
#ifdef LDAP_R_COMPILE LDAP_MUTEX_LOCK( &ld->ld_req_mutex );
ldap_pvt_thread_mutex_lock( &ld->ld_req_mutex );
#endif
rc = do_abandon( ld, msgid, msgid, NULL, 0 ); rc = do_abandon( ld, msgid, msgid, NULL, 0 );
LDAP_MUTEX_UNLOCK( &ld->ld_req_mutex );
#ifdef LDAP_R_COMPILE
ldap_pvt_thread_mutex_unlock( &ld->ld_req_mutex );
#endif
return rc; return rc;
} }
@ -180,13 +169,9 @@ start_again:;
/* ldap_msgdelete locks the res_mutex. Give up the req_mutex /* ldap_msgdelete locks the res_mutex. Give up the req_mutex
* while we're in there. * while we're in there.
*/ */
#ifdef LDAP_R_COMPILE LDAP_MUTEX_UNLOCK( &ld->ld_req_mutex );
ldap_pvt_thread_mutex_unlock( &ld->ld_req_mutex );
#endif
err = ldap_msgdelete( ld, msgid ); err = ldap_msgdelete( ld, msgid );
#ifdef LDAP_R_COMPILE LDAP_MUTEX_LOCK( &ld->ld_req_mutex );
ldap_pvt_thread_mutex_lock( &ld->ld_req_mutex );
#endif
if ( err == 0 ) { if ( err == 0 ) {
ld->ld_errno = LDAP_SUCCESS; ld->ld_errno = LDAP_SUCCESS;
return 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; /* ld_abandoned is actually protected by the ld_res_mutex;
* give up the ld_req_mutex and get the other */ * give up the ld_req_mutex and get the other */
ldap_pvt_thread_mutex_unlock( &ld->ld_req_mutex ); LDAP_MUTEX_UNLOCK( &ld->ld_req_mutex );
ldap_pvt_thread_mutex_lock( &ld->ld_res_mutex ); LDAP_MUTEX_LOCK( &ld->ld_res_mutex );
#endif
/* use bisection */ /* use bisection */
i = 0; i = 0;
@ -321,10 +304,8 @@ start_again:;
ld->ld_errno = LDAP_SUCCESS; ld->ld_errno = LDAP_SUCCESS;
} }
#ifdef LDAP_R_COMPILE LDAP_MUTEX_UNLOCK( &ld->ld_res_mutex );
ldap_pvt_thread_mutex_unlock( &ld->ld_res_mutex ); LDAP_MUTEX_LOCK( &ld->ld_req_mutex );
ldap_pvt_thread_mutex_lock( &ld->ld_req_mutex );
#endif
return( ld->ld_errno ); return( ld->ld_errno );
} }

View File

@ -410,9 +410,7 @@ ldap_int_sasl_bind(
} }
rc = 0; rc = 0;
#ifdef LDAP_R_COMPILE LDAP_MUTEX_LOCK( &ld->ld_req_mutex );
ldap_pvt_thread_mutex_lock( &ld->ld_req_mutex );
#endif
ber_sockbuf_ctrl( ld->ld_sb, LBER_SB_OPT_GET_FD, &sd ); ber_sockbuf_ctrl( ld->ld_sb, LBER_SB_OPT_GET_FD, &sd );
if ( sd == AC_SOCKET_INVALID ) { if ( sd == AC_SOCKET_INVALID ) {
@ -430,9 +428,7 @@ ldap_int_sasl_bind(
} }
} }
} }
#ifdef LDAP_R_COMPILE LDAP_MUTEX_UNLOCK( &ld->ld_req_mutex );
ldap_pvt_thread_mutex_unlock( &ld->ld_req_mutex );
#endif
if( rc != 0 ) return ld->ld_errno; if( rc != 0 ) return ld->ld_errno;
oldctx = ld->ld_defconn->lconn_sasl_authctx; oldctx = ld->ld_defconn->lconn_sasl_authctx;

View File

@ -202,9 +202,7 @@ int ldap_domain2hostlist(
} }
sprintf(request, "_ldap._tcp.%s", domain); sprintf(request, "_ldap._tcp.%s", domain);
#ifdef LDAP_R_COMPILE LDAP_MUTEX_LOCK(&ldap_int_resolv_mutex);
ldap_pvt_thread_mutex_lock(&ldap_int_resolv_mutex);
#endif
rc = LDAP_UNAVAILABLE; rc = LDAP_UNAVAILABLE;
#ifdef NS_HFIXEDSZ #ifdef NS_HFIXEDSZ
@ -305,9 +303,7 @@ add_size:;
*list = hostlist; *list = hostlist;
out: out:
#ifdef LDAP_R_COMPILE LDAP_MUTEX_UNLOCK(&ldap_int_resolv_mutex);
ldap_pvt_thread_mutex_unlock(&ldap_int_resolv_mutex);
#endif
if (request != NULL) { if (request != NULL) {
LDAP_FREE(request); LDAP_FREE(request);

View File

@ -260,9 +260,7 @@ ldap_parse_result(
if(referralsp != NULL) *referralsp = NULL; if(referralsp != NULL) *referralsp = NULL;
if(serverctrls != NULL) *serverctrls = NULL; if(serverctrls != NULL) *serverctrls = NULL;
#ifdef LDAP_R_COMPILE LDAP_MUTEX_LOCK( &ld->ld_res_mutex );
ldap_pvt_thread_mutex_lock( &ld->ld_res_mutex );
#endif
/* Find the result, last msg in chain... */ /* Find the result, last msg in chain... */
lm = r->lm_chain_tail; lm = r->lm_chain_tail;
/* FIXME: either this is not possible (assert?) /* FIXME: either this is not possible (assert?)
@ -282,9 +280,7 @@ ldap_parse_result(
if( lm == NULL ) { if( lm == NULL ) {
errcode = ld->ld_errno = LDAP_NO_RESULTS_RETURNED; errcode = ld->ld_errno = LDAP_NO_RESULTS_RETURNED;
#ifdef LDAP_R_COMPILE LDAP_MUTEX_UNLOCK( &ld->ld_res_mutex );
ldap_pvt_thread_mutex_unlock( &ld->ld_res_mutex );
#endif
goto done; goto done;
} }
@ -390,10 +386,7 @@ ldap_parse_result(
*referralsp = ldap_value_dup( ld->ld_referrals ); *referralsp = ldap_value_dup( ld->ld_referrals );
} }
} }
LDAP_MUTEX_UNLOCK( &ld->ld_res_mutex );
#ifdef LDAP_R_COMPILE
ldap_pvt_thread_mutex_unlock( &ld->ld_res_mutex );
#endif
done: done:
if ( freeit ) { if ( freeit ) {

View File

@ -435,11 +435,22 @@ LDAP_V( ldap_pvt_thread_mutex_t ) ldap_int_gssapi_mutex;
#endif #endif
#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 #ifdef LDAP_R_COMPILE
#define LDAP_NEXT_MSGID(ld, id) \ #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; \ id = ++(ld)->ld_msgid; \
ldap_pvt_thread_mutex_unlock( &(ld)->ld_req_mutex ) LDAP_MUTEX_UNLOCK( &(ld)->ld_req_mutex )
#else #else
#define LDAP_NEXT_MSGID(ld, id) id = ++(ld)->ld_msgid #define LDAP_NEXT_MSGID(ld, id) id = ++(ld)->ld_msgid
#endif #endif

View File

@ -592,16 +592,12 @@ ldap_connect_to_host(LDAP *ld, Sockbuf *sb,
hints.ai_socktype = socktype; hints.ai_socktype = socktype;
snprintf(serv, sizeof serv, "%d", port ); snprintf(serv, sizeof serv, "%d", port );
#ifdef LDAP_R_COMPILE
/* most getaddrinfo(3) use non-threadsafe resolver libraries */ /* most getaddrinfo(3) use non-threadsafe resolver libraries */
ldap_pvt_thread_mutex_lock(&ldap_int_resolv_mutex); LDAP_MUTEX_LOCK(&ldap_int_resolv_mutex);
#endif
err = getaddrinfo( host, serv, &hints, &res ); err = getaddrinfo( host, serv, &hints, &res );
#ifdef LDAP_R_COMPILE LDAP_MUTEX_UNLOCK(&ldap_int_resolv_mutex);
ldap_pvt_thread_mutex_unlock(&ldap_int_resolv_mutex);
#endif
if ( err != 0 ) { if ( err != 0 ) {
osip_debug(ld, "ldap_connect_to_host: getaddrinfo failed: %s\n", osip_debug(ld, "ldap_connect_to_host: getaddrinfo failed: %s\n",

View File

@ -98,17 +98,13 @@ ldap_send_initial_request(
Debug( LDAP_DEBUG_TRACE, "ldap_send_initial_request\n", 0, 0, 0 ); Debug( LDAP_DEBUG_TRACE, "ldap_send_initial_request\n", 0, 0, 0 );
#ifdef LDAP_R_COMPILE LDAP_MUTEX_LOCK( &ld->ld_req_mutex );
ldap_pvt_thread_mutex_lock( &ld->ld_req_mutex );
#endif
if ( ber_sockbuf_ctrl( ld->ld_sb, LBER_SB_OPT_GET_FD, NULL ) == -1 ) { if ( ber_sockbuf_ctrl( ld->ld_sb, LBER_SB_OPT_GET_FD, NULL ) == -1 ) {
/* not connected yet */ /* not connected yet */
rc = ldap_open_defconn( ld ); rc = ldap_open_defconn( ld );
} }
#ifdef LDAP_R_COMPILE LDAP_MUTEX_UNLOCK( &ld->ld_req_mutex );
ldap_pvt_thread_mutex_unlock( &ld->ld_req_mutex );
#endif
if( rc < 0 ) { if( rc < 0 ) {
ber_free( ber, 1 ); ber_free( ber, 1 );
return( -1 ); return( -1 );
@ -134,14 +130,10 @@ ldap_send_initial_request(
} }
} }
#endif #endif
#ifdef LDAP_R_COMPILE LDAP_MUTEX_LOCK( &ld->ld_req_mutex );
ldap_pvt_thread_mutex_lock( &ld->ld_req_mutex );
#endif
rc = ldap_send_server_request( ld, ber, msgid, NULL, rc = ldap_send_server_request( ld, ber, msgid, NULL,
NULL, NULL, NULL ); NULL, NULL, NULL );
#ifdef LDAP_R_COMPILE LDAP_MUTEX_UNLOCK( &ld->ld_req_mutex );
ldap_pvt_thread_mutex_unlock( &ld->ld_req_mutex );
#endif
return(rc); 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; lc->lconn_status = async ? LDAP_CONNST_CONNECTING : LDAP_CONNST_CONNECTED;
#ifdef LDAP_R_COMPILE LDAP_MUTEX_LOCK( &ld->ld_conn_mutex );
ldap_pvt_thread_mutex_lock( &ld->ld_conn_mutex );
#endif
lc->lconn_next = ld->ld_conns; lc->lconn_next = ld->ld_conns;
ld->ld_conns = lc; ld->ld_conns = lc;
#ifdef LDAP_R_COMPILE LDAP_MUTEX_UNLOCK( &ld->ld_conn_mutex );
ldap_pvt_thread_mutex_unlock( &ld->ld_conn_mutex );
#endif
if ( connect ) { if ( connect ) {
#ifdef LDAP_R_COMPILE LDAP_ASSERT_MUTEX_OWNER( &ld->ld_req_mutex );
LDAP_PVT_THREAD_ASSERT_MUTEX_OWNER( &ld->ld_req_mutex ); LDAP_ASSERT_MUTEX_OWNER( &ld->ld_res_mutex );
LDAP_PVT_THREAD_ASSERT_MUTEX_OWNER( &ld->ld_res_mutex );
#endif
#ifdef HAVE_TLS #ifdef HAVE_TLS
if ( lc->lconn_server->lud_exts ) { 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 */ ++lc->lconn_refcnt; /* avoid premature free */
ld->ld_defconn = lc; ld->ld_defconn = lc;
#ifdef LDAP_R_COMPILE LDAP_MUTEX_UNLOCK( &ld->ld_req_mutex );
ldap_pvt_thread_mutex_unlock( &ld->ld_req_mutex ); LDAP_MUTEX_UNLOCK( &ld->ld_res_mutex );
ldap_pvt_thread_mutex_unlock( &ld->ld_res_mutex );
#endif
rc = ldap_start_tls_s( ld, NULL, NULL ); rc = ldap_start_tls_s( ld, NULL, NULL );
#ifdef LDAP_R_COMPILE LDAP_MUTEX_LOCK( &ld->ld_res_mutex );
ldap_pvt_thread_mutex_lock( &ld->ld_res_mutex ); LDAP_MUTEX_LOCK( &ld->ld_req_mutex );
ldap_pvt_thread_mutex_lock( &ld->ld_req_mutex );
#endif
ld->ld_defconn = savedefconn; ld->ld_defconn = savedefconn;
--lc->lconn_refcnt; --lc->lconn_refcnt;
@ -503,10 +485,8 @@ ldap_new_connection( LDAP *ld, LDAPURLDesc **srvlist, int use_ldsb,
int err = 0; int err = 0;
LDAPConn *savedefconn; LDAPConn *savedefconn;
#ifdef LDAP_R_COMPILE LDAP_ASSERT_MUTEX_OWNER( &ld->ld_req_mutex );
LDAP_PVT_THREAD_ASSERT_MUTEX_OWNER( &ld->ld_req_mutex ); LDAP_ASSERT_MUTEX_OWNER( &ld->ld_res_mutex );
LDAP_PVT_THREAD_ASSERT_MUTEX_OWNER( &ld->ld_res_mutex );
#endif
/* Set flag to prevent additional referrals /* Set flag to prevent additional referrals
* from being processed on this * from being processed on this
@ -527,17 +507,13 @@ ldap_new_connection( LDAP *ld, LDAPURLDesc **srvlist, int use_ldsb,
ld->ld_defconn = lc; ld->ld_defconn = lc;
Debug( LDAP_DEBUG_TRACE, "Call application rebind_proc\n", 0, 0, 0); Debug( LDAP_DEBUG_TRACE, "Call application rebind_proc\n", 0, 0, 0);
#ifdef LDAP_R_COMPILE LDAP_MUTEX_UNLOCK( &ld->ld_req_mutex );
ldap_pvt_thread_mutex_unlock( &ld->ld_req_mutex ); LDAP_MUTEX_UNLOCK( &ld->ld_res_mutex );
ldap_pvt_thread_mutex_unlock( &ld->ld_res_mutex );
#endif
err = (*ld->ld_rebind_proc)( ld, err = (*ld->ld_rebind_proc)( ld,
bind->ri_url, bind->ri_request, bind->ri_msgid, bind->ri_url, bind->ri_request, bind->ri_msgid,
ld->ld_rebind_params ); ld->ld_rebind_params );
#ifdef LDAP_R_COMPILE LDAP_MUTEX_LOCK( &ld->ld_res_mutex );
ldap_pvt_thread_mutex_lock( &ld->ld_res_mutex ); LDAP_MUTEX_LOCK( &ld->ld_req_mutex );
ldap_pvt_thread_mutex_lock( &ld->ld_req_mutex );
#endif
ld->ld_defconn = savedefconn; ld->ld_defconn = savedefconn;
--lc->lconn_refcnt; --lc->lconn_refcnt;
@ -562,10 +538,8 @@ ldap_new_connection( LDAP *ld, LDAPURLDesc **srvlist, int use_ldsb,
"anonymous rebind via ldap_sasl_bind(\"\")\n", "anonymous rebind via ldap_sasl_bind(\"\")\n",
0, 0, 0); 0, 0, 0);
#ifdef LDAP_R_COMPILE LDAP_MUTEX_UNLOCK( &ld->ld_req_mutex );
ldap_pvt_thread_mutex_unlock( &ld->ld_req_mutex ); LDAP_MUTEX_UNLOCK( &ld->ld_res_mutex );
ldap_pvt_thread_mutex_unlock( &ld->ld_res_mutex );
#endif
rc = ldap_sasl_bind( ld, "", LDAP_SASL_SIMPLE, &passwd, rc = ldap_sasl_bind( ld, "", LDAP_SASL_SIMPLE, &passwd,
NULL, NULL, &msgid ); NULL, NULL, &msgid );
if ( rc != LDAP_SUCCESS ) { if ( rc != LDAP_SUCCESS ) {
@ -609,10 +583,8 @@ ldap_new_connection( LDAP *ld, LDAPURLDesc **srvlist, int use_ldsb,
} }
} }
} }
#ifdef LDAP_R_COMPILE LDAP_MUTEX_LOCK( &ld->ld_res_mutex );
ldap_pvt_thread_mutex_lock( &ld->ld_res_mutex ); LDAP_MUTEX_LOCK( &ld->ld_req_mutex );
ldap_pvt_thread_mutex_lock( &ld->ld_req_mutex );
#endif
ld->ld_defconn = savedefconn; ld->ld_defconn = savedefconn;
--lc->lconn_refcnt; --lc->lconn_refcnt;
@ -641,9 +613,7 @@ find_connection( LDAP *ld, LDAPURLDesc *srv, int any )
int lcu_port, lsu_port; int lcu_port, lsu_port;
int found = 0; int found = 0;
#ifdef LDAP_R_COMPILE LDAP_MUTEX_LOCK( &ld->ld_conn_mutex );
ldap_pvt_thread_mutex_lock( &ld->ld_conn_mutex );
#endif
for ( lc = ld->ld_conns; lc != NULL; lc = lc->lconn_next ) { for ( lc = ld->ld_conns; lc != NULL; lc = lc->lconn_next ) {
lcu = lc->lconn_server; lcu = lc->lconn_server;
lcu_port = ldap_pvt_url_scheme_port( lcu->lud_scheme, lcu_port = ldap_pvt_url_scheme_port( lcu->lud_scheme,
@ -667,9 +637,7 @@ find_connection( LDAP *ld, LDAPURLDesc *srv, int any )
if ( found ) if ( found )
break; break;
} }
#ifdef LDAP_R_COMPILE LDAP_MUTEX_UNLOCK( &ld->ld_conn_mutex );
ldap_pvt_thread_mutex_unlock( &ld->ld_conn_mutex );
#endif
return lc; return lc;
} }
@ -697,9 +665,7 @@ ldap_free_connection( LDAP *ld, LDAPConn *lc, int force, int unbind )
if ( force || --lc->lconn_refcnt <= 0 ) { if ( force || --lc->lconn_refcnt <= 0 ) {
/* remove from connections list first */ /* remove from connections list first */
#ifdef LDAP_R_COMPILE LDAP_MUTEX_LOCK( &ld->ld_conn_mutex );
ldap_pvt_thread_mutex_lock( &ld->ld_conn_mutex );
#endif
for ( prevlc = NULL, tmplc = ld->ld_conns; for ( prevlc = NULL, tmplc = ld->ld_conns;
tmplc != NULL; tmplc != NULL;
@ -718,9 +684,7 @@ ldap_free_connection( LDAP *ld, LDAPConn *lc, int force, int unbind )
} }
prevlc = tmplc; prevlc = tmplc;
} }
#ifdef LDAP_R_COMPILE LDAP_MUTEX_UNLOCK( &ld->ld_conn_mutex );
ldap_pvt_thread_mutex_unlock( &ld->ld_conn_mutex );
#endif
/* process connection callbacks */ /* process connection callbacks */
{ {
@ -960,9 +924,7 @@ ldap_free_request_int( LDAP *ld, LDAPRequest *lr )
void void
ldap_free_request( LDAP *ld, LDAPRequest *lr ) ldap_free_request( LDAP *ld, LDAPRequest *lr )
{ {
#ifdef LDAP_R_COMPILE LDAP_ASSERT_MUTEX_OWNER( &ld->ld_req_mutex );
LDAP_PVT_THREAD_ASSERT_MUTEX_OWNER( &ld->ld_req_mutex );
#endif
Debug( LDAP_DEBUG_TRACE, "ldap_free_request (origid %d, msgid %d)\n", Debug( LDAP_DEBUG_TRACE, "ldap_free_request (origid %d, msgid %d)\n",
lr->lr_origid, lr->lr_msgid, 0 ); 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 */ /* Send the new request to the server - may require a bind */
rinfo.ri_msgid = origreq->lr_origid; rinfo.ri_msgid = origreq->lr_origid;
rinfo.ri_url = refarray[i]; rinfo.ri_url = refarray[i];
#ifdef LDAP_R_COMPILE LDAP_MUTEX_LOCK( &ld->ld_req_mutex );
ldap_pvt_thread_mutex_lock( &ld->ld_req_mutex );
#endif
rc = ldap_send_server_request( ld, ber, id, rc = ldap_send_server_request( ld, ber, id,
origreq, &srv, NULL, &rinfo ); origreq, &srv, NULL, &rinfo );
#ifdef LDAP_R_COMPILE LDAP_MUTEX_UNLOCK( &ld->ld_req_mutex );
ldap_pvt_thread_mutex_unlock( &ld->ld_req_mutex );
#endif
if ( rc < 0 ) { if ( rc < 0 ) {
/* Failure, try next referral in the list */ /* Failure, try next referral in the list */
Debug( LDAP_DEBUG_ANY, "Unable to chase referral \"%s\" (%d: %s)\n", 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; rinfo.ri_msgid = origreq->lr_origid;
#ifdef LDAP_R_COMPILE LDAP_MUTEX_LOCK( &ld->ld_req_mutex );
ldap_pvt_thread_mutex_lock( &ld->ld_req_mutex );
#endif
rc = ldap_send_server_request( ld, ber, id, rc = ldap_send_server_request( ld, ber, id,
lr, &srv, NULL, &rinfo ); lr, &srv, NULL, &rinfo );
#ifdef LDAP_R_COMPILE LDAP_MUTEX_UNLOCK( &ld->ld_req_mutex );
ldap_pvt_thread_mutex_unlock( &ld->ld_req_mutex );
#endif
LDAP_FREE( rinfo.ri_url ); LDAP_FREE( rinfo.ri_url );
@ -1612,9 +1566,7 @@ ldap_find_request_by_msgid( LDAP *ld, ber_int_t msgid )
{ {
LDAPRequest *lr; LDAPRequest *lr;
#ifdef LDAP_R_COMPILE LDAP_MUTEX_LOCK( &ld->ld_req_mutex );
ldap_pvt_thread_mutex_lock( &ld->ld_req_mutex );
#endif
for ( lr = ld->ld_requests; lr != NULL; lr = lr->lr_next ) { for ( lr = ld->ld_requests; lr != NULL; lr = lr->lr_next ) {
if ( lr->lr_status == LDAP_REQST_COMPLETED ) { if ( lr->lr_status == LDAP_REQST_COMPLETED ) {
continue; /* Skip completed requests */ continue; /* Skip completed requests */
@ -1624,9 +1576,7 @@ ldap_find_request_by_msgid( LDAP *ld, ber_int_t msgid )
break; break;
} }
} }
#ifdef LDAP_R_COMPILE LDAP_MUTEX_UNLOCK( &ld->ld_req_mutex );
ldap_pvt_thread_mutex_unlock( &ld->ld_req_mutex );
#endif
return( lr ); return( lr );
} }
@ -1636,9 +1586,7 @@ ldap_return_request( LDAP *ld, LDAPRequest *lrx, int freeit )
{ {
LDAPRequest *lr; LDAPRequest *lr;
#ifdef LDAP_R_COMPILE LDAP_MUTEX_LOCK( &ld->ld_req_mutex );
ldap_pvt_thread_mutex_lock( &ld->ld_req_mutex );
#endif
for ( lr = ld->ld_requests; lr != NULL; lr = lr->lr_next ) { for ( lr = ld->ld_requests; lr != NULL; lr = lr->lr_next ) {
if ( lr == lrx ) { if ( lr == lrx ) {
if ( lr->lr_refcnt > 0 ) { if ( lr->lr_refcnt > 0 ) {
@ -1659,7 +1607,5 @@ ldap_return_request( LDAP *ld, LDAPRequest *lrx, int freeit )
} else if ( freeit ) { } else if ( freeit ) {
ldap_free_request( ld, lrx ); ldap_free_request( ld, lrx );
} }
#ifdef LDAP_R_COMPILE LDAP_MUTEX_UNLOCK( &ld->ld_req_mutex );
ldap_pvt_thread_mutex_unlock( &ld->ld_req_mutex );
#endif
} }

View File

@ -113,15 +113,9 @@ ldap_result(
Debug( LDAP_DEBUG_TRACE, "ldap_result ld %p msgid %d\n", (void *)ld, msgid, 0 ); Debug( LDAP_DEBUG_TRACE, "ldap_result ld %p msgid %d\n", (void *)ld, msgid, 0 );
#ifdef LDAP_R_COMPILE LDAP_MUTEX_LOCK( &ld->ld_res_mutex );
ldap_pvt_thread_mutex_lock( &ld->ld_res_mutex );
#endif
rc = wait4msg( ld, msgid, all, timeout, result ); rc = wait4msg( ld, msgid, all, timeout, result );
LDAP_MUTEX_UNLOCK( &ld->ld_res_mutex );
#ifdef LDAP_R_COMPILE
ldap_pvt_thread_mutex_unlock( &ld->ld_res_mutex );
#endif
return rc; return rc;
} }
@ -142,9 +136,7 @@ chkResponseList(
* wait until it arrives or timeout occurs. * wait until it arrives or timeout occurs.
*/ */
#ifdef LDAP_R_COMPILE LDAP_ASSERT_MUTEX_OWNER( &ld->ld_res_mutex );
LDAP_PVT_THREAD_ASSERT_MUTEX_OWNER( &ld->ld_res_mutex );
#endif
Debug( LDAP_DEBUG_TRACE, Debug( LDAP_DEBUG_TRACE,
"ldap_chkResponseList ld %p msgid %d all %d\n", "ldap_chkResponseList ld %p msgid %d all %d\n",
@ -257,9 +249,7 @@ wait4msg(
assert( ld != NULL ); assert( ld != NULL );
assert( result != NULL ); assert( result != NULL );
#ifdef LDAP_R_COMPILE LDAP_ASSERT_MUTEX_OWNER( &ld->ld_res_mutex );
LDAP_PVT_THREAD_ASSERT_MUTEX_OWNER( &ld->ld_res_mutex );
#endif
if ( timeout == NULL && ld->ld_options.ldo_tm_api.tv_sec >= 0 ) { if ( timeout == NULL && ld->ld_options.ldo_tm_api.tv_sec >= 0 ) {
tv = ld->ld_options.ldo_tm_api; tv = ld->ld_options.ldo_tm_api;
@ -294,18 +284,12 @@ wait4msg(
if ( ldap_debug & LDAP_DEBUG_TRACE ) { if ( ldap_debug & LDAP_DEBUG_TRACE ) {
Debug( LDAP_DEBUG_TRACE, "wait4msg continue ld %p msgid %d all %d\n", Debug( LDAP_DEBUG_TRACE, "wait4msg continue ld %p msgid %d all %d\n",
(void *)ld, msgid, all ); (void *)ld, msgid, all );
#ifdef LDAP_R_COMPILE LDAP_MUTEX_LOCK( &ld->ld_conn_mutex );
ldap_pvt_thread_mutex_lock( &ld->ld_conn_mutex );
#endif
ldap_dump_connection( ld, ld->ld_conns, 1 ); ldap_dump_connection( ld, ld->ld_conns, 1 );
#ifdef LDAP_R_COMPILE LDAP_MUTEX_UNLOCK( &ld->ld_conn_mutex );
ldap_pvt_thread_mutex_unlock( &ld->ld_conn_mutex ); LDAP_MUTEX_LOCK( &ld->ld_req_mutex );
ldap_pvt_thread_mutex_lock( &ld->ld_req_mutex );
#endif
ldap_dump_requests_and_responses( ld ); ldap_dump_requests_and_responses( ld );
#ifdef LDAP_R_COMPILE LDAP_MUTEX_UNLOCK( &ld->ld_req_mutex );
ldap_pvt_thread_mutex_unlock( &ld->ld_req_mutex );
#endif
} }
#endif /* LDAP_DEBUG */ #endif /* LDAP_DEBUG */
@ -315,9 +299,7 @@ wait4msg(
} else { } else {
int lc_ready = 0; int lc_ready = 0;
#ifdef LDAP_R_COMPILE LDAP_MUTEX_LOCK( &ld->ld_conn_mutex );
ldap_pvt_thread_mutex_lock( &ld->ld_conn_mutex );
#endif
for ( lc = ld->ld_conns; lc != NULL; lc = lc->lconn_next ) { for ( lc = ld->ld_conns; lc != NULL; lc = lc->lconn_next ) {
if ( ber_sockbuf_ctrl( lc->lconn_sb, if ( ber_sockbuf_ctrl( lc->lconn_sb,
LBER_SB_OPT_DATA_READY, NULL ) ) LBER_SB_OPT_DATA_READY, NULL ) )
@ -326,9 +308,7 @@ wait4msg(
break; break;
} }
} }
#ifdef LDAP_R_COMPILE LDAP_MUTEX_UNLOCK( &ld->ld_conn_mutex );
ldap_pvt_thread_mutex_unlock( &ld->ld_conn_mutex );
#endif
if ( !lc_ready ) { if ( !lc_ready ) {
int err; int err;
@ -361,9 +341,7 @@ wait4msg(
if ( lc_ready ) { if ( lc_ready ) {
LDAPConn *lnext; LDAPConn *lnext;
rc = LDAP_MSG_X_KEEP_LOOKING; rc = LDAP_MSG_X_KEEP_LOOKING;
#ifdef LDAP_R_COMPILE LDAP_MUTEX_LOCK( &ld->ld_req_mutex );
ldap_pvt_thread_mutex_lock( &ld->ld_req_mutex );
#endif
if ( ld->ld_requests && if ( ld->ld_requests &&
ld->ld_requests->lr_status == LDAP_REQST_WRITING && ld->ld_requests->lr_status == LDAP_REQST_WRITING &&
ldap_is_write_ready( ld, ldap_is_write_ready( ld,
@ -371,10 +349,8 @@ wait4msg(
{ {
ldap_int_flush_request( ld, ld->ld_requests ); ldap_int_flush_request( ld, ld->ld_requests );
} }
#ifdef LDAP_R_COMPILE LDAP_MUTEX_UNLOCK( &ld->ld_req_mutex );
ldap_pvt_thread_mutex_unlock( &ld->ld_req_mutex ); LDAP_MUTEX_LOCK( &ld->ld_conn_mutex );
ldap_pvt_thread_mutex_lock( &ld->ld_conn_mutex );
#endif
for ( lc = ld->ld_conns; for ( lc = ld->ld_conns;
rc == LDAP_MSG_X_KEEP_LOOKING && lc != NULL; rc == LDAP_MSG_X_KEEP_LOOKING && lc != NULL;
lc = lnext ) lc = lnext )
@ -384,34 +360,24 @@ wait4msg(
{ {
/* Don't let it get freed out from under us */ /* Don't let it get freed out from under us */
++lc->lconn_refcnt; ++lc->lconn_refcnt;
#ifdef LDAP_R_COMPILE LDAP_MUTEX_UNLOCK( &ld->ld_conn_mutex );
ldap_pvt_thread_mutex_unlock( &ld->ld_conn_mutex );
#endif
rc = try_read1msg( ld, msgid, all, lc, result ); rc = try_read1msg( ld, msgid, all, lc, result );
lnext = lc->lconn_next; lnext = lc->lconn_next;
/* Only take locks if we're really freeing */ /* Only take locks if we're really freeing */
if ( lc->lconn_refcnt <= 1 ) { if ( lc->lconn_refcnt <= 1 ) {
#ifdef LDAP_R_COMPILE LDAP_MUTEX_LOCK( &ld->ld_req_mutex );
ldap_pvt_thread_mutex_lock( &ld->ld_req_mutex );
#endif
ldap_free_connection( ld, lc, 0, 1 ); ldap_free_connection( ld, lc, 0, 1 );
#ifdef LDAP_R_COMPILE LDAP_MUTEX_UNLOCK( &ld->ld_req_mutex );
ldap_pvt_thread_mutex_unlock( &ld->ld_req_mutex );
#endif
} else { } else {
--lc->lconn_refcnt; --lc->lconn_refcnt;
} }
#ifdef LDAP_R_COMPILE LDAP_MUTEX_LOCK( &ld->ld_conn_mutex );
ldap_pvt_thread_mutex_lock( &ld->ld_conn_mutex );
#endif
} else { } else {
lnext = lc->lconn_next; lnext = lc->lconn_next;
} }
} }
#ifdef LDAP_R_COMPILE LDAP_MUTEX_UNLOCK( &ld->ld_conn_mutex );
ldap_pvt_thread_mutex_unlock( &ld->ld_conn_mutex );
#endif
} }
} }
@ -494,9 +460,7 @@ try_read1msg(
assert( ld != NULL ); assert( ld != NULL );
assert( lc != NULL ); assert( lc != NULL );
#ifdef LDAP_R_COMPILE LDAP_ASSERT_MUTEX_OWNER( &ld->ld_res_mutex );
LDAP_PVT_THREAD_ASSERT_MUTEX_OWNER( &ld->ld_res_mutex );
#endif
Debug( LDAP_DEBUG_TRACE, "read1msg: ld %p msgid %d all %d\n", Debug( LDAP_DEBUG_TRACE, "read1msg: ld %p msgid %d all %d\n",
(void *)ld, msgid, all ); (void *)ld, msgid, all );
@ -1331,9 +1295,7 @@ ldap_msgdelete( LDAP *ld, int msgid )
Debug( LDAP_DEBUG_TRACE, "ldap_msgdelete ld=%p msgid=%d\n", Debug( LDAP_DEBUG_TRACE, "ldap_msgdelete ld=%p msgid=%d\n",
(void *)ld, msgid, 0 ); (void *)ld, msgid, 0 );
#ifdef LDAP_R_COMPILE LDAP_MUTEX_LOCK( &ld->ld_res_mutex );
ldap_pvt_thread_mutex_lock( &ld->ld_res_mutex );
#endif
prev = NULL; prev = NULL;
for ( lm = ld->ld_responses; lm != NULL; lm = lm->lm_next ) { for ( lm = ld->ld_responses; lm != NULL; lm = lm->lm_next ) {
if ( lm->lm_msgid == msgid ) { if ( lm->lm_msgid == msgid ) {
@ -1352,9 +1314,7 @@ ldap_msgdelete( LDAP *ld, int msgid )
prev->lm_next = lm->lm_next; prev->lm_next = lm->lm_next;
} }
} }
#ifdef LDAP_R_COMPILE LDAP_MUTEX_UNLOCK( &ld->ld_res_mutex );
ldap_pvt_thread_mutex_unlock( &ld->ld_res_mutex );
#endif
if ( lm ) { if ( lm ) {
switch ( ldap_msgfree( lm ) ) { switch ( ldap_msgfree( lm ) ) {
case LDAP_RES_SEARCH_ENTRY: case LDAP_RES_SEARCH_ENTRY:
@ -1383,9 +1343,7 @@ ldap_msgdelete( LDAP *ld, int msgid )
static int static int
ldap_abandoned( LDAP *ld, ber_int_t msgid, int *idxp ) ldap_abandoned( LDAP *ld, ber_int_t msgid, int *idxp )
{ {
#ifdef LDAP_R_COMPILE LDAP_ASSERT_MUTEX_OWNER( &ld->ld_res_mutex );
LDAP_PVT_THREAD_ASSERT_MUTEX_OWNER( &ld->ld_res_mutex );
#endif
assert( idxp != NULL ); assert( idxp != NULL );
assert( msgid >= 0 ); assert( msgid >= 0 );
@ -1401,9 +1359,7 @@ ldap_abandoned( LDAP *ld, ber_int_t msgid, int *idxp )
static int static int
ldap_mark_abandoned( LDAP *ld, ber_int_t msgid, int idx ) ldap_mark_abandoned( LDAP *ld, ber_int_t msgid, int idx )
{ {
#ifdef LDAP_R_COMPILE LDAP_ASSERT_MUTEX_OWNER( &ld->ld_res_mutex );
LDAP_PVT_THREAD_ASSERT_MUTEX_OWNER( &ld->ld_res_mutex );
#endif
/* NOTE: those assertions are repeated in ldap_int_bisect_delete() */ /* NOTE: those assertions are repeated in ldap_int_bisect_delete() */
assert( idx >= 0 ); assert( idx >= 0 );

View File

@ -422,8 +422,8 @@ ldap_sasl_interactive_bind_s(
int rc; int rc;
char *smechs = NULL; char *smechs = NULL;
#if defined( LDAP_R_COMPILE ) && defined( HAVE_CYRUS_SASL ) #if defined( HAVE_CYRUS_SASL )
ldap_pvt_thread_mutex_lock( &ldap_int_sasl_mutex ); LDAP_MUTEX_LOCK( &ldap_int_sasl_mutex );
#endif #endif
#ifdef LDAP_CONNECTIONLESS #ifdef LDAP_CONNECTIONLESS
if( LDAP_IS_UDP(ld) ) { if( LDAP_IS_UDP(ld) ) {
@ -466,8 +466,8 @@ ldap_sasl_interactive_bind_s(
flags, interact, defaults ); flags, interact, defaults );
done: done:
#if defined( LDAP_R_COMPILE ) && defined( HAVE_CYRUS_SASL ) #if defined( HAVE_CYRUS_SASL )
ldap_pvt_thread_mutex_unlock( &ldap_int_sasl_mutex ); LDAP_MUTEX_UNLOCK( &ldap_int_sasl_mutex );
#endif #endif
if ( smechs ) LDAP_FREE( smechs ); if ( smechs ) LDAP_FREE( smechs );

View File

@ -81,9 +81,7 @@ ldap_ld_free(
int err = LDAP_SUCCESS; int err = LDAP_SUCCESS;
/* free LDAP structure and outstanding requests/responses */ /* free LDAP structure and outstanding requests/responses */
#ifdef LDAP_R_COMPILE LDAP_MUTEX_LOCK( &ld->ld_req_mutex );
ldap_pvt_thread_mutex_lock( &ld->ld_req_mutex );
#endif
while ( ld->ld_requests != NULL ) { while ( ld->ld_requests != NULL ) {
ldap_free_request( ld, ld->ld_requests ); ldap_free_request( ld, ld->ld_requests );
} }
@ -92,13 +90,9 @@ ldap_ld_free(
while ( ld->ld_conns != NULL ) { while ( ld->ld_conns != NULL ) {
ldap_free_connection( ld, ld->ld_conns, 1, close ); ldap_free_connection( ld, ld->ld_conns, 1, close );
} }
#ifdef LDAP_R_COMPILE LDAP_MUTEX_UNLOCK( &ld->ld_req_mutex );
ldap_pvt_thread_mutex_unlock( &ld->ld_req_mutex );
#endif
#ifdef LDAP_R_COMPILE LDAP_MUTEX_LOCK( &ld->ld_res_mutex );
ldap_pvt_thread_mutex_lock( &ld->ld_res_mutex );
#endif
for ( lm = ld->ld_responses; lm != NULL; lm = next ) { for ( lm = ld->ld_responses; lm != NULL; lm = next ) {
next = lm->lm_next; next = lm->lm_next;
ldap_msgfree( lm ); ldap_msgfree( lm );
@ -108,9 +102,7 @@ ldap_ld_free(
LDAP_FREE( ld->ld_abandoned ); LDAP_FREE( ld->ld_abandoned );
ld->ld_abandoned = NULL; ld->ld_abandoned = NULL;
} }
#ifdef LDAP_R_COMPILE LDAP_MUTEX_UNLOCK( &ld->ld_res_mutex );
ldap_pvt_thread_mutex_unlock( &ld->ld_res_mutex );
#endif
/* final close callbacks */ /* final close callbacks */
{ {

View File

@ -107,15 +107,9 @@ char *ldap_pvt_ctime( const time_t *tp, char *buf )
#else #else
# ifdef LDAP_R_COMPILE LDAP_MUTEX_LOCK( &ldap_int_ctime_mutex );
ldap_pvt_thread_mutex_lock( &ldap_int_ctime_mutex );
# endif
AC_MEMCPY( buf, ctime(tp), 26 ); AC_MEMCPY( buf, ctime(tp), 26 );
LDAP_MUTEX_UNLOCK( &ldap_int_ctime_mutex );
# ifdef LDAP_R_COMPILE
ldap_pvt_thread_mutex_unlock( &ldap_int_ctime_mutex );
# endif
return buf; return buf;
#endif #endif
@ -128,7 +122,7 @@ ldap_pvt_gmtime_lock( void )
# ifndef LDAP_R_COMPILE # ifndef LDAP_R_COMPILE
return 0; return 0;
# else /* LDAP_R_COMPILE */ # else /* LDAP_R_COMPILE */
return ldap_pvt_thread_mutex_lock( &ldap_int_gmtime_mutex ); return LDAP_MUTEX_LOCK( &ldap_int_gmtime_mutex );
# endif /* LDAP_R_COMPILE */ # endif /* LDAP_R_COMPILE */
} }
@ -138,7 +132,7 @@ ldap_pvt_gmtime_unlock( void )
# ifndef LDAP_R_COMPILE # ifndef LDAP_R_COMPILE
return 0; return 0;
# else /* LDAP_R_COMPILE */ # else /* LDAP_R_COMPILE */
return ldap_pvt_thread_mutex_unlock( &ldap_int_gmtime_mutex ); return LDAP_MUTEX_UNLOCK( &ldap_int_gmtime_mutex );
# endif /* LDAP_R_COMPILE */ # endif /* LDAP_R_COMPILE */
} }
#endif /* !USE_GMTIME_R || !USE_LOCALTIME_R */ #endif /* !USE_GMTIME_R || !USE_LOCALTIME_R */
@ -149,10 +143,7 @@ ldap_pvt_gmtime( const time_t *timep, struct tm *result )
{ {
struct tm *tm_ptr; struct tm *tm_ptr;
# ifdef LDAP_R_COMPILE LDAP_MUTEX_LOCK( &ldap_int_gmtime_mutex );
ldap_pvt_thread_mutex_lock( &ldap_int_gmtime_mutex );
# endif /* LDAP_R_COMPILE */
tm_ptr = gmtime( timep ); tm_ptr = gmtime( timep );
if ( tm_ptr == NULL ) { if ( tm_ptr == NULL ) {
result = NULL; result = NULL;
@ -160,10 +151,7 @@ ldap_pvt_gmtime( const time_t *timep, struct tm *result )
} else { } else {
*result = *tm_ptr; *result = *tm_ptr;
} }
LDAP_MUTEX_UNLOCK( &ldap_int_gmtime_mutex );
# ifdef LDAP_R_COMPILE
ldap_pvt_thread_mutex_unlock( &ldap_int_gmtime_mutex );
# endif /* LDAP_R_COMPILE */
return result; return result;
} }
@ -175,10 +163,7 @@ ldap_pvt_localtime( const time_t *timep, struct tm *result )
{ {
struct tm *tm_ptr; struct tm *tm_ptr;
# ifdef LDAP_R_COMPILE LDAP_MUTEX_LOCK( &ldap_int_gmtime_mutex );
ldap_pvt_thread_mutex_lock( &ldap_int_gmtime_mutex );
# endif /* LDAP_R_COMPILE */
tm_ptr = localtime( timep ); tm_ptr = localtime( timep );
if ( tm_ptr == NULL ) { if ( tm_ptr == NULL ) {
result = NULL; result = NULL;
@ -186,10 +171,7 @@ ldap_pvt_localtime( const time_t *timep, struct tm *result )
} else { } else {
*result = *tm_ptr; *result = *tm_ptr;
} }
LDAP_MUTEX_UNLOCK( &ldap_int_gmtime_mutex );
# ifdef LDAP_R_COMPILE
ldap_pvt_thread_mutex_unlock( &ldap_int_gmtime_mutex );
# endif /* LDAP_R_COMPILE */
return result; return result;
} }
@ -385,7 +367,7 @@ int ldap_pvt_gethostbyname_a(
int retval; int retval;
*buf = NULL; *buf = NULL;
ldap_pvt_thread_mutex_lock( &ldap_int_resolv_mutex ); LDAP_MUTEX_LOCK( &ldap_int_resolv_mutex );
he = gethostbyname( name ); he = gethostbyname( name );
@ -400,7 +382,7 @@ int ldap_pvt_gethostbyname_a(
retval = 0; retval = 0;
} }
ldap_pvt_thread_mutex_unlock( &ldap_int_resolv_mutex ); LDAP_MUTEX_UNLOCK( &ldap_int_resolv_mutex );
return retval; return retval;
#else #else
@ -444,13 +426,9 @@ int ldap_pvt_get_hname(
int rc; int rc;
#if defined( HAVE_GETNAMEINFO ) #if defined( HAVE_GETNAMEINFO )
#if defined( LDAP_R_COMPILE ) LDAP_MUTEX_LOCK( &ldap_int_resolv_mutex );
ldap_pvt_thread_mutex_lock( &ldap_int_resolv_mutex );
#endif
rc = getnameinfo( sa, len, name, namelen, NULL, 0, 0 ); rc = getnameinfo( sa, len, name, namelen, NULL, 0, 0 );
#if defined( LDAP_R_COMPILE ) LDAP_MUTEX_UNLOCK( &ldap_int_resolv_mutex );
ldap_pvt_thread_mutex_unlock( &ldap_int_resolv_mutex );
#endif
if ( rc ) *err = (char *)AC_GAI_STRERROR( rc ); if ( rc ) *err = (char *)AC_GAI_STRERROR( rc );
return rc; return rc;
@ -514,9 +492,7 @@ int ldap_pvt_get_hname(
LDAP_FREE(buf); LDAP_FREE(buf);
#else /* HAVE_GETHOSTBYADDR_R */ #else /* HAVE_GETHOSTBYADDR_R */
#if defined( LDAP_R_COMPILE ) LDAP_MUTEX_LOCK( &ldap_int_resolv_mutex );
ldap_pvt_thread_mutex_lock( &ldap_int_resolv_mutex );
#endif
hp = gethostbyaddr( addr, alen, sa->sa_family ); hp = gethostbyaddr( addr, alen, sa->sa_family );
if (hp) { if (hp) {
strncpy( name, hp->h_name, namelen ); strncpy( name, hp->h_name, namelen );
@ -525,9 +501,7 @@ int ldap_pvt_get_hname(
rc = h_errno; rc = h_errno;
*err = (char *)HSTRERROR( h_errno ); *err = (char *)HSTRERROR( h_errno );
} }
#if defined( LDAP_R_COMPILE ) LDAP_MUTEX_UNLOCK( &ldap_int_resolv_mutex );
ldap_pvt_thread_mutex_unlock( &ldap_int_resolv_mutex );
#endif
#endif /* !HAVE_GETHOSTBYADDR_R */ #endif /* !HAVE_GETHOSTBYADDR_R */
return rc; return rc;
@ -582,8 +556,7 @@ int ldap_pvt_gethostbyaddr_a(
int retval; int retval;
*buf = NULL; *buf = NULL;
ldap_pvt_thread_mutex_lock( &ldap_int_resolv_mutex ); LDAP_MUTEX_LOCK( &ldap_int_resolv_mutex );
he = gethostbyaddr( addr, len, type ); he = gethostbyaddr( addr, len, type );
if (he==NULL) { if (he==NULL) {
@ -596,8 +569,7 @@ int ldap_pvt_gethostbyaddr_a(
*result = resbuf; *result = resbuf;
retval = 0; retval = 0;
} }
LDAP_MUTEX_UNLOCK( &ldap_int_resolv_mutex );
ldap_pvt_thread_mutex_unlock( &ldap_int_resolv_mutex );
return retval; return retval;