From 5c89312cdfe484e7b8e4cf32427d7576aa4ba2ac Mon Sep 17 00:00:00 2001
From: Noriko Hosoi <nhosoi@redhat.com>
Date: Mon, 11 Jan 2016 15:53:28 -0800
Subject: [PATCH 373/375] Ticket #48406 - Avoid self deadlock by
PR_Lock(conn->c_mutex)
Description: Fixing ticket 48338 introduced a self deadlock.
To avoid the self deadlock, tried to remove PR_Lock(conn->c_mutex)
which looked harmless, but it introduced a crash by memory corruption.
This patch replaces PR_Lock/Unlock with PR_EnterMonitor/ExitMonitor,
respectively.
https://fedorahosted.org/389/ticket/48406
Reviewed by rmeggins@redhat.com, lkrispen@redhat.com, and wibrown@redhat.com.
Thank you, Rich, Ludwig and William!
(cherry picked from commit f25f804a8bce83b3790e7045dfc03230d7ece1af)
(cherry picked from commit 84da7d05ddc5a963b0d025df08f38a6ccd7d90d2)
(cherry picked from commit ad08d1fa7c258bb99cd64a4de570035d82e6a492)
(cherry picked from commit f69d19a351a34313c5f45499718c892a9bb3b42a)
---
ldap/servers/slapd/abandon.c | 4 +-
ldap/servers/slapd/bind.c | 4 +-
ldap/servers/slapd/connection.c | 88 +++++++++++++++---------------
ldap/servers/slapd/conntable.c | 19 +++----
ldap/servers/slapd/daemon.c | 14 ++---
ldap/servers/slapd/extendop.c | 10 ++--
ldap/servers/slapd/opshared.c | 18 +++----
ldap/servers/slapd/pagedresults.c | 100 +++++++++++++++++------------------
ldap/servers/slapd/pblock.c | 72 ++++++++++++-------------
ldap/servers/slapd/psearch.c | 8 +--
ldap/servers/slapd/saslbind.c | 26 ++++-----
ldap/servers/slapd/slap.h | 2 +-
ldap/servers/slapd/start_tls_extop.c | 15 +++---
ldap/servers/slapd/unbind.c | 4 +-
14 files changed, 192 insertions(+), 192 deletions(-)
diff --git a/ldap/servers/slapd/abandon.c b/ldap/servers/slapd/abandon.c
index 09da149..06a17e1 100644
--- a/ldap/servers/slapd/abandon.c
+++ b/ldap/servers/slapd/abandon.c
@@ -108,7 +108,7 @@ do_abandon( Slapi_PBlock *pb )
* flag and abort the operation at a convenient time.
*/
- PR_Lock( pb->pb_conn->c_mutex );
+ PR_EnterMonitor(pb->pb_conn->c_mutex);
for ( o = pb->pb_conn->c_ops; o != NULL; o = o->o_next ) {
if ( o->o_msgid == id && o != pb->pb_op)
break;
@@ -170,7 +170,7 @@ do_abandon( Slapi_PBlock *pb )
}
- PR_Unlock( pb->pb_conn->c_mutex );
+ PR_ExitMonitor(pb->pb_conn->c_mutex);
/*
* Wake up the persistent searches, so they
* can notice if they've been abandoned.
diff --git a/ldap/servers/slapd/bind.c b/ldap/servers/slapd/bind.c
index 11ec22e..bc8040f 100644
--- a/ldap/servers/slapd/bind.c
+++ b/ldap/servers/slapd/bind.c
@@ -290,7 +290,7 @@ do_bind( Slapi_PBlock *pb )
slapi_pblock_get (pb, SLAPI_PWPOLICY, &pw_response_requested);
}
- PR_Lock( pb->pb_conn->c_mutex );
+ PR_EnterMonitor(pb->pb_conn->c_mutex);
bind_credentials_clear( pb->pb_conn, PR_FALSE, /* do not lock conn */
PR_FALSE /* do not clear external creds. */ );
@@ -323,7 +323,7 @@ do_bind( Slapi_PBlock *pb )
* bound user can work properly
*/
pb->pb_conn->c_needpw = 0;
- PR_Unlock( pb->pb_conn->c_mutex );
+ PR_ExitMonitor(pb->pb_conn->c_mutex);
log_bind_access(pb, dn?dn:"empty", method, version, saslmech, NULL);
diff --git a/ldap/servers/slapd/connection.c b/ldap/servers/slapd/connection.c
index c2ec4a7..d0387fc 100644
--- a/ldap/servers/slapd/connection.c
+++ b/ldap/servers/slapd/connection.c
@@ -111,7 +111,7 @@ connection_done(Connection *conn)
}
if (NULL != conn->c_mutex)
{
- PR_DestroyLock(conn->c_mutex);
+ PR_DestroyMonitor(conn->c_mutex);
}
if (NULL != conn->c_pdumutex)
{
@@ -703,10 +703,10 @@ int connection_is_free (Connection *conn)
{
int rc;
- PR_Lock(conn->c_mutex);
+ PR_EnterMonitor(conn->c_mutex);
rc = conn->c_sd == SLAPD_INVALID_SOCKET && conn->c_refcnt == 0 &&
!(conn->c_flags & CONN_FLAG_CLOSING);
- PR_Unlock(conn->c_mutex);
+ PR_ExitMonitor(conn->c_mutex);
return rc;
}
@@ -748,17 +748,17 @@ static void inc_op_count(Connection* conn)
static int connection_increment_reference(Connection *conn)
{
int rc = 0;
- PR_Lock( conn->c_mutex );
+ PR_EnterMonitor(conn->c_mutex);
rc = connection_acquire_nolock (conn);
- PR_Unlock( conn->c_mutex );
+ PR_ExitMonitor(conn->c_mutex);
return rc;
}
static void connection_decrement_reference(Connection *conn)
{
- PR_Lock( conn->c_mutex );
+ PR_EnterMonitor(conn->c_mutex);
connection_release_nolock (conn);
- PR_Unlock( conn->c_mutex );
+ PR_ExitMonitor(conn->c_mutex);
}
static void
@@ -990,29 +990,29 @@ done:
* If not a persistent search, remove the operation
* from this connection's list.
*/
- PR_Lock( conn->c_mutex );
+ PR_EnterMonitor(conn->c_mutex);
connection_remove_operation( conn, op );
- PR_Unlock( conn->c_mutex );
+ PR_ExitMonitor(conn->c_mutex);
/* destroying the pblock will cause destruction of the operation
* so this must happen before releasing the connection
*/
slapi_pblock_destroy( pb );
- PR_Lock( conn->c_mutex );
+ PR_EnterMonitor(conn->c_mutex);
if (connection_release_nolock (conn) != 0)
{
return_value = -1;
}
- PR_Unlock( conn->c_mutex );
+ PR_ExitMonitor(conn->c_mutex);
} else { /* ps code acquires ref to conn - we need to release ours here */
- PR_Lock( conn->c_mutex );
+ PR_EnterMonitor(conn->c_mutex);
if (connection_release_nolock (conn) != 0)
{
return_value = -1;
}
- PR_Unlock( conn->c_mutex );
+ PR_ExitMonitor(conn->c_mutex);
}
return return_value;
}
@@ -1075,19 +1075,19 @@ static int connection_operation_new(Connection *conn, Operation **ppOp)
Operation *temp_op = NULL;
int rc;
- PR_Lock( conn->c_mutex );
+ PR_EnterMonitor(conn->c_mutex);
if (connection_is_active_nolock(conn) == 0) {
LDAPDebug(LDAP_DEBUG_CONNS,
"not creating a new operation when conn %" NSPRIu64 " closing\n",
conn->c_connid,0,0);
- PR_Unlock( conn->c_mutex );
+ PR_ExitMonitor(conn->c_mutex);
return -1;
}
temp_op = operation_new( plugin_build_operation_action_bitmap( 0,
plugin_get_server_plg() ));
connection_add_operation( conn, temp_op);
rc = connection_acquire_nolock (conn);
- PR_Unlock( conn->c_mutex );
+ PR_ExitMonitor(conn->c_mutex);
/* Stash the op pointer in the connection structure for later use */
PR_ASSERT(NULL == conn->c_private->c_current_op);
conn->c_private->c_current_op = temp_op;
@@ -1173,21 +1173,21 @@ static int read_the_data(Connection *conn, int *process_op, int *defer_io, int *
"conn=%" NSPRIu64 " fd=%d The length of BER Element was too long.\n",
conn->c_connid, conn->c_sd );
}
- PR_Lock( conn->c_mutex );
+ PR_EnterMonitor(conn->c_mutex);
connection_remove_operation( conn, op );
operation_free(&op, conn);
priv->c_current_op = NULL;
- PR_Unlock( conn->c_mutex );
+ PR_ExitMonitor(conn->c_mutex);
return -1; /* Abandon Connection */
}
}
if (is_ber_too_big(conn,ber_len))
{
- PR_Lock( conn->c_mutex );
+ PR_EnterMonitor(conn->c_mutex);
connection_remove_operation( conn, op );
operation_free(&op, conn);
priv->c_current_op = NULL;
- PR_Unlock( conn->c_mutex );
+ PR_ExitMonitor(conn->c_mutex);
return -1; /* Abandon Connection */
}
@@ -1210,11 +1210,11 @@ static int read_the_data(Connection *conn, int *process_op, int *defer_io, int *
"conn=%" NSPRIu64 " received a non-LDAP message"
" (tag 0x%lx, expected 0x%lx)\n",
conn->c_connid, tag, LDAP_TAG_MESSAGE );
- PR_Lock( conn->c_mutex );
+ PR_EnterMonitor(conn->c_mutex);
connection_remove_operation( conn, op );
operation_free(&op, conn);
priv->c_current_op = NULL;
- PR_Unlock( conn->c_mutex );
+ PR_ExitMonitor(conn->c_mutex);
return -1; /* Abandon Connection */
}
}
@@ -1891,10 +1891,10 @@ int connection_read_operation(Connection *conn, Operation *op, ber_tag_t *tag, i
if (ret <= 0) {
if (0 == ret) {
/* Connection is closed */
- PR_Lock( conn->c_mutex );
+ PR_EnterMonitor(conn->c_mutex);
disconnect_server_nomutex( conn, conn->c_connid, -1, SLAPD_DISCONNECT_BAD_BER_TAG, 0 );
conn->c_gettingber = 0;
- PR_Unlock( conn->c_mutex );
+ PR_ExitMonitor(conn->c_mutex);
signal_listner();
return CONN_DONE;
}
@@ -2024,9 +2024,9 @@ int connection_read_operation(Connection *conn, Operation *op, ber_tag_t *tag, i
void connection_make_readable(Connection *conn)
{
- PR_Lock( conn->c_mutex );
+ PR_EnterMonitor(conn->c_mutex);
conn->c_gettingber = 0;
- PR_Unlock( conn->c_mutex );
+ PR_ExitMonitor(conn->c_mutex);
signal_listner();
}
@@ -2037,7 +2037,7 @@ void connection_check_activity_level(Connection *conn)
{
int current_count = 0;
int delta_count = 0;
- PR_Lock( conn->c_mutex );
+ PR_EnterMonitor(conn->c_mutex);
/* get the current op count */
current_count = conn->c_opscompleted;
/* compare to the previous op count */
@@ -2048,7 +2048,7 @@ void connection_check_activity_level(Connection *conn)
conn->c_private->previous_op_count = current_count;
/* update the last checked time */
conn->c_private->previous_count_check_time = current_time();
- PR_Unlock( conn->c_mutex );
+ PR_ExitMonitor(conn->c_mutex);
LDAPDebug(LDAP_DEBUG_CONNS,"conn %" NSPRIu64 " activity level = %d\n",conn->c_connid,delta_count,0);
}
@@ -2092,7 +2092,7 @@ void connection_enter_leave_turbo(Connection *conn, int current_turbo_flag, int
int connection_count = 0;
int our_rank = 0;
int threshold_rank = 0;
- PR_Lock(conn->c_mutex);
+ PR_EnterMonitor(conn->c_mutex);
/* We can already be in turbo mode, or not */
current_mode = current_turbo_flag;
if (pagedresults_in_use_nolock(conn)) {
@@ -2148,7 +2148,7 @@ void connection_enter_leave_turbo(Connection *conn, int current_turbo_flag, int
}
}
}
- PR_Unlock(conn->c_mutex);
+ PR_ExitMonitor(conn->c_mutex);
if (current_mode != new_mode) {
if (current_mode) {
LDAPDebug(LDAP_DEBUG_CONNS,"conn %" NSPRIu64 " leaving turbo mode\n",conn->c_connid,0,0);
@@ -2244,13 +2244,13 @@ connection_threadmain()
*/
PR_Sleep(PR_INTERVAL_NO_WAIT);
- PR_Lock(conn->c_mutex);
+ PR_EnterMonitor(conn->c_mutex);
/* Make our own pb in turbo mode */
connection_make_new_pb(&pb,conn);
if (connection_call_io_layer_callbacks(conn)) {
LDAPDebug0Args( LDAP_DEBUG_ANY, "Error: could not add/remove IO layers from connection\n" );
}
- PR_Unlock(conn->c_mutex);
+ PR_ExitMonitor(conn->c_mutex);
if (! config_check_referral_mode()) {
slapi_counter_increment(ops_initiated);
slapi_counter_increment(g_get_global_snmp_vars()->ops_tbl.dsInOps);
@@ -2374,7 +2374,7 @@ done:
/* If this op isn't a persistent search, remove it */
if ( !( pb->pb_op->o_flags & OP_FLAG_PS )) {
/* delete from connection operation queue & decr refcnt */
- PR_Lock( conn->c_mutex );
+ PR_EnterMonitor(conn->c_mutex);
connection_remove_operation( conn, op );
/* destroying the pblock will cause destruction of the operation
* so this must happend before releasing the connection
@@ -2386,11 +2386,11 @@ done:
if (!thread_turbo_flag && !more_data) {
connection_release_nolock (conn);
}
- PR_Unlock( conn->c_mutex );
+ PR_ExitMonitor(conn->c_mutex);
} else { /* the ps code acquires a ref to the conn - we need to release ours here */
- PR_Lock( conn->c_mutex );
+ PR_EnterMonitor(conn->c_mutex);
connection_release_nolock (conn);
- PR_Unlock( conn->c_mutex );
+ PR_ExitMonitor(conn->c_mutex);
}
/* Since we didn't do so earlier, we need to make a replication connection readable again here */
if ( ((1 == is_timedout) || (replication_connection && !thread_turbo_flag)) && !more_data)
@@ -2401,7 +2401,7 @@ done:
}
if (!thread_turbo_flag && !more_data) { /* Don't do this in turbo mode */
- PR_Lock( conn->c_mutex );
+ PR_EnterMonitor(conn->c_mutex);
/* if the threadnumber of now below the maximum, wakeup
* the listener thread so that we start polling on this
* connection again
@@ -2412,7 +2412,7 @@ done:
else
need_wakeup = 0;
conn->c_threadnumber--;
- PR_Unlock( conn->c_mutex );
+ PR_ExitMonitor(conn->c_mutex);
if (need_wakeup)
signal_listner();
@@ -2647,7 +2647,7 @@ op_copy_identity(Connection *conn, Operation *op)
size_t dnlen;
size_t typelen;
- PR_Lock( conn->c_mutex );
+ PR_EnterMonitor(conn->c_mutex);
dnlen= conn->c_dn ? strlen (conn->c_dn) : 0;
typelen= conn->c_authtype ? strlen (conn->c_authtype) : 0;
@@ -2679,14 +2679,14 @@ op_copy_identity(Connection *conn, Operation *op)
op->o_ssf = conn->c_local_ssf;
}
- PR_Unlock( conn->c_mutex );
+ PR_ExitMonitor(conn->c_mutex);
}
/* Sets the SSL SSF in the connection struct. */
static void
connection_set_ssl_ssf(Connection *conn)
{
- PR_Lock( conn->c_mutex );
+ PR_EnterMonitor(conn->c_mutex);
if (conn->c_flags & CONN_FLAG_SSL) {
SSL_SecurityStatus(conn->c_prfd, NULL, NULL, NULL, &(conn->c_ssl_ssf), NULL, NULL);
@@ -2694,7 +2694,7 @@ connection_set_ssl_ssf(Connection *conn)
conn->c_ssl_ssf = 0;
}
- PR_Unlock( conn->c_mutex );
+ PR_ExitMonitor(conn->c_mutex);
}
static int
@@ -2741,9 +2741,9 @@ log_ber_too_big_error(const Connection *conn, ber_len_t ber_len,
void
disconnect_server( Connection *conn, PRUint64 opconnid, int opid, PRErrorCode reason, PRInt32 error )
{
- PR_Lock( conn->c_mutex );
+ PR_EnterMonitor(conn->c_mutex);
disconnect_server_nomutex( conn, opconnid, opid, reason, error );
- PR_Unlock( conn->c_mutex );
+ PR_ExitMonitor(conn->c_mutex);
}
static ps_wakeup_all_fn_ptr ps_wakeup_all_fn = NULL;
diff --git a/ldap/servers/slapd/conntable.c b/ldap/servers/slapd/conntable.c
index 7cf9f31..5917401 100644
--- a/ldap/servers/slapd/conntable.c
+++ b/ldap/servers/slapd/conntable.c
@@ -141,11 +141,11 @@ connection_table_abandon_all_operations(Connection_Table *ct)
int i;
for ( i = 0; i < ct->size; i++ )
{
- if ( ct->c[i].c_mutex != NULL )
+ if ( ct->c[i].c_mutex )
{
- PR_Lock( ct->c[i].c_mutex );
+ PR_EnterMonitor(ct->c[i].c_mutex);
connection_abandon_operations( &ct->c[i] );
- PR_Unlock( ct->c[i].c_mutex );
+ PR_ExitMonitor(ct->c[i].c_mutex);
}
}
}
@@ -195,7 +195,7 @@ connection_table_get_connection(Connection_Table *ct, int sd)
if ( c->c_mutex == NULL )
{
PR_Lock( ct->table_mutex );
- c->c_mutex = PR_NewLock();
+ c->c_mutex = PR_NewMonitor();
c->c_pdumutex = PR_NewLock();
PR_Unlock( ct->table_mutex );
if ( c->c_mutex == NULL || c->c_pdumutex == NULL )
@@ -399,7 +399,7 @@ connection_table_as_entry(Connection_Table *ct, Slapi_Entry *e)
/* Can't take c_mutex if holding table_mutex; temporarily unlock */
PR_Unlock( ct->table_mutex );
- PR_Lock( ct->c[i].c_mutex );
+ PR_EnterMonitor(ct->c[i].c_mutex);
if ( ct->c[i].c_sd != SLAPD_INVALID_SOCKET )
{
char buf2[20];
@@ -446,7 +446,7 @@ connection_table_as_entry(Connection_Table *ct, Slapi_Entry *e)
attrlist_merge( &e->e_attrs, "connection", vals );
slapi_ch_free_string(&newbuf);
}
- PR_Unlock( ct->c[i].c_mutex );
+ PR_ExitMonitor(ct->c[i].c_mutex);
}
PR_snprintf( buf, sizeof(buf), "%d", nconns );
@@ -474,14 +474,15 @@ void
connection_table_dump_activity_to_errors_log(Connection_Table *ct)
{
int i;
+
for ( i = 0; i < ct->size; i++ )
{
Connection *c= &(ct->c[i]);
- if ( c->c_mutex != NULL )
+ if ( c->c_mutex )
{
/* Find the connection we are referring to */
int j= c->c_fdi;
- PR_Lock( c->c_mutex );
+ PR_EnterMonitor(c->c_mutex);
if ( (c->c_sd != SLAPD_INVALID_SOCKET) &&
(j >= 0) && (c->c_prfd == ct->fd[j].fd) )
{
@@ -491,7 +492,7 @@ connection_table_dump_activity_to_errors_log(Connection_Table *ct)
LDAPDebug( LDAP_DEBUG_CONNS,"activity on %d%s\n", i, r ? "r" : "",0 );
}
}
- PR_Unlock( c->c_mutex );
+ PR_ExitMonitor(c->c_mutex);
}
}
}
diff --git a/ldap/servers/slapd/daemon.c b/ldap/servers/slapd/daemon.c
index 9a362c7..b34358d 100644
--- a/ldap/servers/slapd/daemon.c
+++ b/ldap/servers/slapd/daemon.c
@@ -1678,7 +1678,7 @@ setup_pr_read_pds(Connection_Table *ct, PRFileDesc **n_tcps, PRFileDesc **s_tcps
}
else
{
- PR_Lock( c->c_mutex );
+ PR_EnterMonitor(c->c_mutex);
if (c->c_flags & CONN_FLAG_CLOSING)
{
/* A worker thread has marked that this connection
@@ -1724,7 +1724,7 @@ setup_pr_read_pds(Connection_Table *ct, PRFileDesc **n_tcps, PRFileDesc **s_tcps
c->c_fdi = SLAPD_INVALID_SOCKET_INDEX;
}
}
- PR_Unlock( c->c_mutex );
+ PR_ExitMonitor(c->c_mutex);
}
c = next;
}
@@ -1743,7 +1743,7 @@ handle_timeout( void )
time_t curtime = current_time();
if (0 == prevtime) {
- prevtime = time (&housekeeping_fire_time);
+ prevtime = time (&housekeeping_fire_time);
}
if ( difftime(curtime, prevtime) >=
@@ -1979,7 +1979,7 @@ handle_pr_read_ready(Connection_Table *ct, PRIntn num_poll)
{
if ( c->c_mutex != NULL )
{
- PR_Lock( c->c_mutex );
+ PR_EnterMonitor(c->c_mutex);
if ( connection_is_active_nolock (c) && c->c_gettingber == 0 )
{
PRInt16 out_flags;
@@ -2036,7 +2036,7 @@ handle_pr_read_ready(Connection_Table *ct, PRIntn num_poll)
SLAPD_DISCONNECT_IDLE_TIMEOUT, EAGAIN );
}
}
- PR_Unlock( c->c_mutex );
+ PR_ExitMonitor(c->c_mutex);
}
}
#endif
@@ -2611,7 +2611,7 @@ handle_new_connection(Connection_Table *ct, int tcps, PRFileDesc *pr_acceptfd, i
PR_Close(pr_acceptfd);
return -1;
}
- PR_Lock( conn->c_mutex );
+ PR_EnterMonitor(conn->c_mutex);
/*
* Set the default idletimeout and the handle. We'll update c_idletimeout
@@ -2721,7 +2721,7 @@ handle_new_connection(Connection_Table *ct, int tcps, PRFileDesc *pr_acceptfd, i
connection_table_move_connection_on_to_active_list(the_connection_table,conn);
}
- PR_Unlock( conn->c_mutex );
+ PR_ExitMonitor(conn->c_mutex);
g_increment_current_conn_count();
diff --git a/ldap/servers/slapd/extendop.c b/ldap/servers/slapd/extendop.c
index 8f25b27..0a0615c 100644
--- a/ldap/servers/slapd/extendop.c
+++ b/ldap/servers/slapd/extendop.c
@@ -90,7 +90,7 @@ static void extop_handle_import_start(Slapi_PBlock *pb, char *extoid,
send_ldap_result(pb, LDAP_OPERATIONS_ERROR, NULL, NULL, 0, NULL);
return;
}
- suffix = slapi_sdn_get_dn(sdn);
+ suffix = slapi_sdn_get_dn(sdn);
/* be = slapi_be_select(sdn); */
be = slapi_mapping_tree_find_backend_for_sdn(sdn);
if (be == NULL || be == defbackend_get_backend()) {
@@ -164,10 +164,10 @@ static void extop_handle_import_start(Slapi_PBlock *pb, char *extoid,
/* okay, the import is starting now -- save the backend in the
* connection block & mark this connection as belonging to a bulk import
*/
- PR_Lock(pb->pb_conn->c_mutex);
+ PR_EnterMonitor(pb->pb_conn->c_mutex);
pb->pb_conn->c_flags |= CONN_FLAG_IMPORT;
pb->pb_conn->c_bi_backend = be;
- PR_Unlock(pb->pb_conn->c_mutex);
+ PR_ExitMonitor(pb->pb_conn->c_mutex);
slapi_pblock_set(pb, SLAPI_EXT_OP_RET_OID, EXTOP_BULK_IMPORT_START_OID);
bv.bv_val = NULL;
@@ -189,11 +189,11 @@ static void extop_handle_import_done(Slapi_PBlock *pb, char *extoid,
struct berval bv;
int ret;
- PR_Lock(pb->pb_conn->c_mutex);
+ PR_EnterMonitor(pb->pb_conn->c_mutex);
pb->pb_conn->c_flags &= ~CONN_FLAG_IMPORT;
be = pb->pb_conn->c_bi_backend;
pb->pb_conn->c_bi_backend = NULL;
- PR_Unlock(pb->pb_conn->c_mutex);
+ PR_ExitMonitor(pb->pb_conn->c_mutex);
if ((be == NULL) || (be->be_wire_import == NULL)) {
/* can this even happen? */
diff --git a/ldap/servers/slapd/opshared.c b/ldap/servers/slapd/opshared.c
index e73ac6e..6ddbc91 100644
--- a/ldap/servers/slapd/opshared.c
+++ b/ldap/servers/slapd/opshared.c
@@ -700,7 +700,7 @@ op_shared_search (Slapi_PBlock *pb, int send_result)
* In async paged result case, the search result might be released
* by other theads. We need to double check it in the locked region.
*/
- PR_Lock(pb->pb_conn->c_mutex);
+ PR_EnterMonitor(pb->pb_conn->c_mutex);
pr_search_result = pagedresults_get_search_result(pb->pb_conn, operation, 1/*locked*/, pr_idx);
if (pr_search_result) {
if (pagedresults_is_abandoned_or_notavailable(pb->pb_conn, 1/*locked*/, pr_idx)) {
@@ -708,7 +708,7 @@ op_shared_search (Slapi_PBlock *pb, int send_result)
/* Previous operation was abandoned and the simplepaged object is not in use. */
send_ldap_result(pb, 0, NULL, "Simple Paged Results Search abandoned", 0, NULL);
rc = LDAP_SUCCESS;
- PR_Unlock(pb->pb_conn->c_mutex);
+ PR_ExitMonitor(pb->pb_conn->c_mutex);
goto free_and_return;
} else {
slapi_pblock_set( pb, SLAPI_SEARCH_RESULT_SET, pr_search_result );
@@ -717,7 +717,7 @@ op_shared_search (Slapi_PBlock *pb, int send_result)
/* search result could be reset in the backend/dse */
slapi_pblock_get(pb, SLAPI_SEARCH_RESULT_SET, &sr);
pagedresults_set_search_result(pb->pb_conn, operation, sr, 1/*locked*/, pr_idx);
- PR_Unlock(pb->pb_conn->c_mutex);
+ PR_ExitMonitor(pb->pb_conn->c_mutex);
}
} else {
pr_stat = PAGEDRESULTS_SEARCH_END;
@@ -851,10 +851,10 @@ op_shared_search (Slapi_PBlock *pb, int send_result)
/* PAGED RESULTS */
if (op_is_pagedresults(operation)) {
/* cleanup the slot */
- PR_Lock(pb->pb_conn->c_mutex);
+ PR_EnterMonitor(pb->pb_conn->c_mutex);
pagedresults_set_search_result(pb->pb_conn, operation, NULL, 1, pr_idx);
rc = pagedresults_set_current_be(pb->pb_conn, NULL, pr_idx, 1);
- PR_Unlock(pb->pb_conn->c_mutex);
+ PR_ExitMonitor(pb->pb_conn->c_mutex);
}
if (1 == flag_no_such_object) {
break;
@@ -896,11 +896,11 @@ op_shared_search (Slapi_PBlock *pb, int send_result)
slapi_pblock_get(pb, SLAPI_SEARCH_RESULT_SET, &sr);
if (PAGEDRESULTS_SEARCH_END == pr_stat) {
/* no more entries, but at least another backend */
- PR_Lock(pb->pb_conn->c_mutex);
+ PR_EnterMonitor(pb->pb_conn->c_mutex);
pagedresults_set_search_result(pb->pb_conn, operation, NULL, 1, pr_idx);
be->be_search_results_release(&sr);
rc = pagedresults_set_current_be(pb->pb_conn, next_be, pr_idx, 1);
- PR_Unlock(pb->pb_conn->c_mutex);
+ PR_ExitMonitor(pb->pb_conn->c_mutex);
if (NULL == next_be) {
/* no more entries && no more backends */
curr_search_count = -1;
@@ -925,9 +925,9 @@ op_shared_search (Slapi_PBlock *pb, int send_result)
next_be = NULL; /* to break the loop */
if (operation->o_status & SLAPI_OP_STATUS_ABANDONED) {
/* It turned out this search was abandoned. */
- PR_Lock(pb->pb_conn->c_mutex);
+ PR_EnterMonitor(pb->pb_conn->c_mutex);
pagedresults_free_one_msgid_nolock( pb->pb_conn, operation->o_msgid);
- PR_Unlock(pb->pb_conn->c_mutex);
+ PR_ExitMonitor(pb->pb_conn->c_mutex);
/* paged-results-request was abandoned; making an empty cookie. */
pagedresults_set_response_control(pb, 0, estimate, -1, pr_idx);
send_ldap_result(pb, 0, NULL, "Simple Paged Results Search abandoned", 0, NULL);
diff --git a/ldap/servers/slapd/pagedresults.c b/ldap/servers/slapd/pagedresults.c
index c1947f1..d10edd0 100644
--- a/ldap/servers/slapd/pagedresults.c
+++ b/ldap/servers/slapd/pagedresults.c
@@ -119,7 +119,7 @@ pagedresults_parse_control_value( Slapi_PBlock *pb,
return LDAP_PROTOCOL_ERROR;
}
- PR_Lock(conn->c_mutex);
+ PR_EnterMonitor(conn->c_mutex);
/* the ber encoding is no longer needed */
ber_free(ber, 1);
if ( cookie.bv_len <= 0 ) {
@@ -217,7 +217,7 @@ bail:
}
}
}
- PR_Unlock(conn->c_mutex);
+ PR_ExitMonitor(conn->c_mutex);
LDAPDebug1Arg(LDAP_DEBUG_TRACE,
"<-- pagedresults_parse_control_value: idx %d\n", *index);
@@ -314,7 +314,7 @@ pagedresults_free_one( Connection *conn, Operation *op, int index )
LDAPDebug1Arg(LDAP_DEBUG_TRACE,
"--> pagedresults_free_one: idx=%d\n", index);
if (conn && (index > -1)) {
- PR_Lock(conn->c_mutex);
+ PR_EnterMonitor(conn->c_mutex);
if (conn->c_pagedresults.prl_count <= 0) {
LDAPDebug2Args(LDAP_DEBUG_TRACE, "pagedresults_free_one: "
"conn=%d paged requests list count is %d\n",
@@ -325,7 +325,7 @@ pagedresults_free_one( Connection *conn, Operation *op, int index )
conn->c_pagedresults.prl_count--;
rc = 0;
}
- PR_Unlock(conn->c_mutex);
+ PR_ExitMonitor(conn->c_mutex);
}
LDAPDebug1Arg(LDAP_DEBUG_TRACE, "<-- pagedresults_free_one: %d\n", rc);
@@ -377,11 +377,11 @@ pagedresults_get_current_be(Connection *conn, int index)
LDAPDebug1Arg(LDAP_DEBUG_TRACE,
"--> pagedresults_get_current_be: idx=%d\n", index);
if (conn && (index > -1)) {
- PR_Lock(conn->c_mutex);
+ PR_EnterMonitor(conn->c_mutex);
if (index < conn->c_pagedresults.prl_maxlen) {
be = conn->c_pagedresults.prl_list[index].pr_current_be;
}
- PR_Unlock(conn->c_mutex);
+ PR_ExitMonitor(conn->c_mutex);
}
LDAPDebug1Arg(LDAP_DEBUG_TRACE,
"<-- pagedresults_get_current_be: %p\n", be);
@@ -395,12 +395,12 @@ pagedresults_set_current_be(Connection *conn, Slapi_Backend *be, int index, int
LDAPDebug1Arg(LDAP_DEBUG_TRACE,
"--> pagedresults_set_current_be: idx=%d\n", index);
if (conn && (index > -1)) {
- if (!nolock) PR_Lock(conn->c_mutex);
+ if (!nolock) PR_EnterMonitor(conn->c_mutex);
if (index < conn->c_pagedresults.prl_maxlen) {
conn->c_pagedresults.prl_list[index].pr_current_be = be;
}
rc = 0;
- if (!nolock) PR_Unlock(conn->c_mutex);
+ if (!nolock) PR_ExitMonitor(conn->c_mutex);
}
LDAPDebug1Arg(LDAP_DEBUG_TRACE,
"<-- pagedresults_set_current_be: %d\n", rc);
@@ -419,13 +419,13 @@ pagedresults_get_search_result(Connection *conn, Operation *op, int locked, int
locked?"locked":"not locked", index);
if (conn && (index > -1)) {
if (!locked) {
- PR_Lock(conn->c_mutex);
+ PR_EnterMonitor(conn->c_mutex);
}
if (index < conn->c_pagedresults.prl_maxlen) {
sr = conn->c_pagedresults.prl_list[index].pr_search_result_set;
}
if (!locked) {
- PR_Unlock(conn->c_mutex);
+ PR_ExitMonitor(conn->c_mutex);
}
}
LDAPDebug1Arg(LDAP_DEBUG_TRACE,
@@ -444,7 +444,7 @@ pagedresults_set_search_result(Connection *conn, Operation *op, void *sr, int lo
"--> pagedresults_set_search_result: idx=%d, sr=%p\n",
index, sr);
if (conn && (index > -1)) {
- if (!locked) PR_Lock(conn->c_mutex);
+ if (!locked) PR_EnterMonitor(conn->c_mutex);
if (index < conn->c_pagedresults.prl_maxlen) {
PagedResults *prp = conn->c_pagedresults.prl_list + index;
if (!(prp->pr_flags & CONN_FLAG_PAGEDRESULTS_ABANDONED) || !sr) {
@@ -453,7 +453,7 @@ pagedresults_set_search_result(Connection *conn, Operation *op, void *sr, int lo
}
rc = 0;
}
- if (!locked) PR_Unlock(conn->c_mutex);
+ if (!locked) PR_ExitMonitor(conn->c_mutex);
}
LDAPDebug1Arg(LDAP_DEBUG_TRACE,
"<-- pagedresults_set_search_result: %d\n", rc);
@@ -470,11 +470,11 @@ pagedresults_get_search_result_count(Connection *conn, Operation *op, int index)
LDAPDebug1Arg(LDAP_DEBUG_TRACE,
"--> pagedresults_get_search_result_count: idx=%d\n", index);
if (conn && (index > -1)) {
- PR_Lock(conn->c_mutex);
+ PR_EnterMonitor(conn->c_mutex);
if (index < conn->c_pagedresults.prl_maxlen) {
count = conn->c_pagedresults.prl_list[index].pr_search_result_count;
}
- PR_Unlock(conn->c_mutex);
+ PR_ExitMonitor(conn->c_mutex);
}
LDAPDebug1Arg(LDAP_DEBUG_TRACE,
"<-- pagedresults_get_search_result_count: %d\n", count);
@@ -492,11 +492,11 @@ pagedresults_set_search_result_count(Connection *conn, Operation *op,
LDAPDebug1Arg(LDAP_DEBUG_TRACE,
"--> pagedresults_set_search_result_count: idx=%d\n", index);
if (conn && (index > -1)) {
- PR_Lock(conn->c_mutex);
+ PR_EnterMonitor(conn->c_mutex);
if (index < conn->c_pagedresults.prl_maxlen) {
conn->c_pagedresults.prl_list[index].pr_search_result_count = count;
}
- PR_Unlock(conn->c_mutex);
+ PR_ExitMonitor(conn->c_mutex);
rc = 0;
}
LDAPDebug1Arg(LDAP_DEBUG_TRACE,
@@ -517,11 +517,11 @@ pagedresults_get_search_result_set_size_estimate(Connection *conn,
"--> pagedresults_get_search_result_set_size_estimate: "
"idx=%d\n", index);
if (conn && (index > -1)) {
- PR_Lock(conn->c_mutex);
+ PR_EnterMonitor(conn->c_mutex);
if (index < conn->c_pagedresults.prl_maxlen) {
count = conn->c_pagedresults.prl_list[index].pr_search_result_set_size_estimate;
}
- PR_Unlock(conn->c_mutex);
+ PR_ExitMonitor(conn->c_mutex);
}
LDAPDebug1Arg(LDAP_DEBUG_TRACE,
"<-- pagedresults_get_search_result_set_size_estimate: %d\n",
@@ -542,11 +542,11 @@ pagedresults_set_search_result_set_size_estimate(Connection *conn,
"--> pagedresults_set_search_result_set_size_estimate: "
"idx=%d\n", index);
if (conn && (index > -1)) {
- PR_Lock(conn->c_mutex);
+ PR_EnterMonitor(conn->c_mutex);
if (index < conn->c_pagedresults.prl_maxlen) {
conn->c_pagedresults.prl_list[index].pr_search_result_set_size_estimate = count;
}
- PR_Unlock(conn->c_mutex);
+ PR_ExitMonitor(conn->c_mutex);
rc = 0;
}
LDAPDebug1Arg(LDAP_DEBUG_TRACE,
@@ -565,11 +565,11 @@ pagedresults_get_with_sort(Connection *conn, Operation *op, int index)
LDAPDebug1Arg(LDAP_DEBUG_TRACE,
"--> pagedresults_get_with_sort: idx=%d\n", index);
if (conn && (index > -1)) {
- PR_Lock(conn->c_mutex);
+ PR_EnterMonitor(conn->c_mutex);
if (index < conn->c_pagedresults.prl_maxlen) {
flags = conn->c_pagedresults.prl_list[index].pr_flags&CONN_FLAG_PAGEDRESULTS_WITH_SORT;
}
- PR_Unlock(conn->c_mutex);
+ PR_ExitMonitor(conn->c_mutex);
}
LDAPDebug1Arg(LDAP_DEBUG_TRACE,
"<-- pagedresults_get_with_sort: %p\n", flags);
@@ -587,14 +587,14 @@ pagedresults_set_with_sort(Connection *conn, Operation *op,
LDAPDebug1Arg(LDAP_DEBUG_TRACE,
"--> pagedresults_set_with_sort: idx=%d\n", index);
if (conn && (index > -1)) {
- PR_Lock(conn->c_mutex);
+ PR_EnterMonitor(conn->c_mutex);
if (index < conn->c_pagedresults.prl_maxlen) {
if (flags & OP_FLAG_SERVER_SIDE_SORTING) {
conn->c_pagedresults.prl_list[index].pr_flags |=
CONN_FLAG_PAGEDRESULTS_WITH_SORT;
}
}
- PR_Unlock(conn->c_mutex);
+ PR_ExitMonitor(conn->c_mutex);
rc = 0;
}
LDAPDebug1Arg(LDAP_DEBUG_TRACE, "<-- pagedresults_set_with_sort: %d\n", rc);
@@ -611,11 +611,11 @@ pagedresults_get_unindexed(Connection *conn, Operation *op, int index)
LDAPDebug1Arg(LDAP_DEBUG_TRACE,
"--> pagedresults_get_unindexed: idx=%d\n", index);
if (conn && (index > -1)) {
- PR_Lock(conn->c_mutex);
+ PR_EnterMonitor(conn->c_mutex);
if (index < conn->c_pagedresults.prl_maxlen) {
flags = conn->c_pagedresults.prl_list[index].pr_flags&CONN_FLAG_PAGEDRESULTS_UNINDEXED;
}
- PR_Unlock(conn->c_mutex);
+ PR_ExitMonitor(conn->c_mutex);
}
LDAPDebug1Arg(LDAP_DEBUG_TRACE,
"<-- pagedresults_get_unindexed: %p\n", flags);
@@ -632,12 +632,12 @@ pagedresults_set_unindexed(Connection *conn, Operation *op, int index)
LDAPDebug1Arg(LDAP_DEBUG_TRACE,
"--> pagedresults_set_unindexed: idx=%d\n", index);
if (conn && (index > -1)) {
- PR_Lock(conn->c_mutex);
+ PR_EnterMonitor(conn->c_mutex);
if (index < conn->c_pagedresults.prl_maxlen) {
conn->c_pagedresults.prl_list[index].pr_flags |=
CONN_FLAG_PAGEDRESULTS_UNINDEXED;
}
- PR_Unlock(conn->c_mutex);
+ PR_ExitMonitor(conn->c_mutex);
rc = 0;
}
LDAPDebug1Arg(LDAP_DEBUG_TRACE,
@@ -655,11 +655,11 @@ pagedresults_get_sort_result_code(Connection *conn, Operation *op, int index)
LDAPDebug1Arg(LDAP_DEBUG_TRACE,
"--> pagedresults_get_sort_result_code: idx=%d\n", index);
if (conn && (index > -1)) {
- PR_Lock(conn->c_mutex);
+ PR_EnterMonitor(conn->c_mutex);
if (index < conn->c_pagedresults.prl_maxlen) {
code = conn->c_pagedresults.prl_list[index].pr_sort_result_code;
}
- PR_Unlock(conn->c_mutex);
+ PR_ExitMonitor(conn->c_mutex);
}
LDAPDebug1Arg(LDAP_DEBUG_TRACE,
"<-- pagedresults_get_sort_result_code: %d\n", code);
@@ -677,11 +677,11 @@ pagedresults_set_sort_result_code(Connection *conn, Operation *op,
LDAPDebug1Arg(LDAP_DEBUG_TRACE,
"--> pagedresults_set_sort_result_code: idx=%d\n", index);
if (conn && (index > -1)) {
- PR_Lock(conn->c_mutex);
+ PR_EnterMonitor(conn->c_mutex);
if (index < conn->c_pagedresults.prl_maxlen) {
conn->c_pagedresults.prl_list[index].pr_sort_result_code = code;
}
- PR_Unlock(conn->c_mutex);
+ PR_ExitMonitor(conn->c_mutex);
rc = 0;
}
LDAPDebug1Arg(LDAP_DEBUG_TRACE,
@@ -700,11 +700,11 @@ pagedresults_set_timelimit(Connection *conn, Operation *op,
LDAPDebug1Arg(LDAP_DEBUG_TRACE,
"--> pagedresults_set_timelimit: idx=%d\n", index);
if (conn && (index > -1)) {
- PR_Lock(conn->c_mutex);
+ PR_EnterMonitor(conn->c_mutex);
if (index < conn->c_pagedresults.prl_maxlen) {
conn->c_pagedresults.prl_list[index].pr_timelimit = timelimit;
}
- PR_Unlock(conn->c_mutex);
+ PR_ExitMonitor(conn->c_mutex);
rc = 0;
}
LDAPDebug1Arg(LDAP_DEBUG_TRACE, "<-- pagedresults_set_timelimit: %d\n", rc);
@@ -762,7 +762,7 @@ pagedresults_cleanup(Connection *conn, int needlock)
}
if (needlock) {
- PR_Lock(conn->c_mutex);
+ PR_EnterMonitor(conn->c_mutex);
}
for (i = 0; conn->c_pagedresults.prl_list &&
i < conn->c_pagedresults.prl_maxlen; i++) {
@@ -780,7 +780,7 @@ pagedresults_cleanup(Connection *conn, int needlock)
}
conn->c_pagedresults.prl_count = 0;
if (needlock) {
- PR_Unlock(conn->c_mutex);
+ PR_ExitMonitor(conn->c_mutex);
}
LDAPDebug1Arg(LDAP_DEBUG_TRACE, "<-- pagedresults_cleanup: %d\n", rc);
return rc;
@@ -807,7 +807,7 @@ pagedresults_cleanup_all(Connection *conn, int needlock)
}
if (needlock) {
- PR_Lock(conn->c_mutex);
+ PR_EnterMonitor(conn->c_mutex);
}
for (i = 0; conn->c_pagedresults.prl_list &&
i < conn->c_pagedresults.prl_maxlen; i++) {
@@ -826,7 +826,7 @@ pagedresults_cleanup_all(Connection *conn, int needlock)
conn->c_pagedresults.prl_maxlen = 0;
conn->c_pagedresults.prl_count = 0;
if (needlock) {
- PR_Unlock(conn->c_mutex);
+ PR_ExitMonitor(conn->c_mutex);
}
LDAPDebug1Arg(LDAP_DEBUG_TRACE, "<-- pagedresults_cleanup_all: %d\n", rc);
return rc;
@@ -845,7 +845,7 @@ pagedresults_check_or_set_processing(Connection *conn, int index)
LDAPDebug1Arg(LDAP_DEBUG_TRACE,
"--> pagedresults_check_or_set_processing\n", index);
if (conn && (index > -1)) {
- PR_Lock(conn->c_mutex);
+ PR_EnterMonitor(conn->c_mutex);
if (index < conn->c_pagedresults.prl_maxlen) {
ret = (conn->c_pagedresults.prl_list[index].pr_flags &
CONN_FLAG_PAGEDRESULTS_PROCESSING);
@@ -853,7 +853,7 @@ pagedresults_check_or_set_processing(Connection *conn, int index)
conn->c_pagedresults.prl_list[index].pr_flags |=
CONN_FLAG_PAGEDRESULTS_PROCESSING;
}
- PR_Unlock(conn->c_mutex);
+ PR_ExitMonitor(conn->c_mutex);
}
LDAPDebug1Arg(LDAP_DEBUG_TRACE,
"<-- pagedresults_check_or_set_processing: %d\n", ret);
@@ -872,7 +872,7 @@ pagedresults_reset_processing(Connection *conn, int index)
LDAPDebug1Arg(LDAP_DEBUG_TRACE,
"--> pagedresults_reset_processing: idx=%d\n", index);
if (conn && (index > -1)) {
- PR_Lock(conn->c_mutex);
+ PR_EnterMonitor(conn->c_mutex);
if (index < conn->c_pagedresults.prl_maxlen) {
ret = (conn->c_pagedresults.prl_list[index].pr_flags &
CONN_FLAG_PAGEDRESULTS_PROCESSING);
@@ -880,7 +880,7 @@ pagedresults_reset_processing(Connection *conn, int index)
conn->c_pagedresults.prl_list[index].pr_flags &=
~CONN_FLAG_PAGEDRESULTS_PROCESSING;
}
- PR_Unlock(conn->c_mutex);
+ PR_ExitMonitor(conn->c_mutex);
}
LDAPDebug1Arg(LDAP_DEBUG_TRACE,
"<-- pagedresults_reset_processing: %d\n", ret);
@@ -994,9 +994,9 @@ pagedresults_lock( Connection *conn, int index )
if (!conn || (index < 0) || (index >= conn->c_pagedresults.prl_maxlen)) {
return;
}
- PR_Lock(conn->c_mutex);
+ PR_EnterMonitor(conn->c_mutex);
prp = conn->c_pagedresults.prl_list + index;
- PR_Unlock(conn->c_mutex);
+ PR_ExitMonitor(conn->c_mutex);
if (prp->pr_mutex) {
PR_Lock(prp->pr_mutex);
}
@@ -1010,9 +1010,9 @@ pagedresults_unlock( Connection *conn, int index )
if (!conn || (index < 0) || (index >= conn->c_pagedresults.prl_maxlen)) {
return;
}
- PR_Lock(conn->c_mutex);
+ PR_EnterMonitor(conn->c_mutex);
prp = conn->c_pagedresults.prl_list + index;
- PR_Unlock(conn->c_mutex);
+ PR_ExitMonitor(conn->c_mutex);
if (prp->pr_mutex) {
PR_Unlock(prp->pr_mutex);
}
@@ -1027,11 +1027,11 @@ pagedresults_is_abandoned_or_notavailable(Connection *conn, int locked, int inde
return 1; /* not abandoned, but do not want to proceed paged results op. */
}
if (!locked) {
- PR_Lock(conn->c_mutex);
+ PR_EnterMonitor(conn->c_mutex);
}
prp = conn->c_pagedresults.prl_list + index;
if (!locked) {
- PR_Unlock(conn->c_mutex);
+ PR_ExitMonitor(conn->c_mutex);
}
return prp->pr_flags & CONN_FLAG_PAGEDRESULTS_ABANDONED;
}
@@ -1055,12 +1055,12 @@ pagedresults_set_search_result_pb(Slapi_PBlock *pb, void *sr, int locked)
LDAPDebug2Args(LDAP_DEBUG_TRACE,
"--> pagedresults_set_search_result_pb: idx=%d, sr=%p\n", index, sr);
if (conn && (index > -1)) {
- if (!locked) PR_Lock(conn->c_mutex);
+ if (!locked) PR_EnterMonitor(conn->c_mutex);
if (index < conn->c_pagedresults.prl_maxlen) {
conn->c_pagedresults.prl_list[index].pr_search_result_set = sr;
rc = 0;
}
- if (!locked) PR_Unlock(conn->c_mutex);
+ if (!locked) PR_ExitMonitor(conn->c_mutex);
}
LDAPDebug1Arg(LDAP_DEBUG_TRACE,
"<-- pagedresults_set_search_result_pb: %d\n", rc);
diff --git a/ldap/servers/slapd/pblock.c b/ldap/servers/slapd/pblock.c
index b12881b..40d0358 100644
--- a/ldap/servers/slapd/pblock.c
+++ b/ldap/servers/slapd/pblock.c
@@ -145,7 +145,7 @@ if ( PBLOCK ->pb_plugin->plg_type != TYPE) return( -1 )
int
slapi_pblock_get( Slapi_PBlock *pblock, int arg, void *value )
{
- char *authtype;
+ char *authtype;
Slapi_Backend *be;
PR_ASSERT( NULL != pblock );
@@ -202,10 +202,10 @@ slapi_pblock_get( Slapi_PBlock *pblock, int arg, void *value )
"Connection is NULL and hence cannot access SLAPI_CONN_DN \n", 0, 0, 0 );
return (-1);
}
- PR_Lock( pblock->pb_conn->c_mutex );
+ PR_EnterMonitor(pblock->pb_conn->c_mutex);
(*(char **)value) = (NULL == pblock->pb_conn->c_dn ? NULL :
slapi_ch_strdup( pblock->pb_conn->c_dn ));
- PR_Unlock( pblock->pb_conn->c_mutex );
+ PR_ExitMonitor(pblock->pb_conn->c_mutex);
break;
case SLAPI_CONN_AUTHTYPE:/* deprecated */
if (pblock->pb_conn == NULL) {
@@ -213,9 +213,9 @@ slapi_pblock_get( Slapi_PBlock *pblock, int arg, void *value )
"Connection is NULL and hence cannot access SLAPI_CONN_AUTHTYPE \n", 0, 0, 0 );
return (-1);
}
- PR_Lock( pblock->pb_conn->c_mutex );
- authtype = pblock->pb_conn->c_authtype;
- PR_Unlock( pblock->pb_conn->c_mutex );
+ PR_EnterMonitor(pblock->pb_conn->c_mutex);
+ authtype = pblock->pb_conn->c_authtype;
+ PR_ExitMonitor(pblock->pb_conn->c_mutex);
if (authtype == NULL) {
(*(char **)value) = NULL;
} else if (strcasecmp(authtype, SLAPD_AUTH_NONE) == 0) {
@@ -240,10 +240,10 @@ slapi_pblock_get( Slapi_PBlock *pblock, int arg, void *value )
"Connection is NULL and hence cannot access SLAPI_CONN_AUTHMETHOD \n", 0, 0, 0 );
return (-1);
}
- PR_Lock( pblock->pb_conn->c_mutex );
+ PR_EnterMonitor(pblock->pb_conn->c_mutex);
(*(char **)value) = pblock->pb_conn->c_authtype ?
slapi_ch_strdup(pblock->pb_conn->c_authtype) : NULL;
- PR_Unlock( pblock->pb_conn->c_mutex );
+ PR_ExitMonitor(pblock->pb_conn->c_mutex);
break;
case SLAPI_CONN_CLIENTNETADDR:
if (pblock->pb_conn == NULL)
@@ -251,14 +251,14 @@ slapi_pblock_get( Slapi_PBlock *pblock, int arg, void *value )
memset( value, 0, sizeof( PRNetAddr ));
break;
}
- PR_Lock( pblock->pb_conn->c_mutex );
+ PR_EnterMonitor(pblock->pb_conn->c_mutex);
if ( pblock->pb_conn->cin_addr == NULL ) {
memset( value, 0, sizeof( PRNetAddr ));
} else {
(*(PRNetAddr *)value) =
*(pblock->pb_conn->cin_addr);
}
- PR_Unlock( pblock->pb_conn->c_mutex );
+ PR_ExitMonitor(pblock->pb_conn->c_mutex);
break;
case SLAPI_CONN_SERVERNETADDR:
if (pblock->pb_conn == NULL)
@@ -266,14 +266,14 @@ slapi_pblock_get( Slapi_PBlock *pblock, int arg, void *value )
memset( value, 0, sizeof( PRNetAddr ));
break;
}
- PR_Lock( pblock->pb_conn->c_mutex );
+ PR_EnterMonitor(pblock->pb_conn->c_mutex);
if ( pblock->pb_conn->cin_destaddr == NULL ) {
memset( value, 0, sizeof( PRNetAddr ));
} else {
(*(PRNetAddr *)value) =
*(pblock->pb_conn->cin_destaddr);
}
- PR_Unlock( pblock->pb_conn->c_mutex );
+ PR_ExitMonitor(pblock->pb_conn->c_mutex);
break;
case SLAPI_CONN_CLIENTIP:
if (pblock->pb_conn == NULL)
@@ -281,7 +281,7 @@ slapi_pblock_get( Slapi_PBlock *pblock, int arg, void *value )
memset( value, 0, sizeof( struct in_addr ));
break;
}
- PR_Lock( pblock->pb_conn->c_mutex );
+ PR_EnterMonitor(pblock->pb_conn->c_mutex);
if ( pblock->pb_conn->cin_addr == NULL ) {
memset( value, 0, sizeof( struct in_addr ));
} else {
@@ -296,7 +296,7 @@ slapi_pblock_get( Slapi_PBlock *pblock, int arg, void *value )
memset( value, 0, sizeof( struct in_addr ));
}
}
- PR_Unlock( pblock->pb_conn->c_mutex );
+ PR_ExitMonitor(pblock->pb_conn->c_mutex);
break;
case SLAPI_CONN_SERVERIP:
if (pblock->pb_conn == NULL)
@@ -304,7 +304,7 @@ slapi_pblock_get( Slapi_PBlock *pblock, int arg, void *value )
memset( value, 0, sizeof( struct in_addr ));
break;
}
- PR_Lock( pblock->pb_conn->c_mutex );
+ PR_EnterMonitor(pblock->pb_conn->c_mutex);
if ( pblock->pb_conn->cin_destaddr == NULL ) {
memset( value, 0, sizeof( PRNetAddr ));
} else {
@@ -320,7 +320,7 @@ slapi_pblock_get( Slapi_PBlock *pblock, int arg, void *value )
}
}
- PR_Unlock( pblock->pb_conn->c_mutex );
+ PR_ExitMonitor(pblock->pb_conn->c_mutex);
break;
case SLAPI_CONN_IS_REPLICATION_SESSION:
if (pblock->pb_conn == NULL) {
@@ -328,9 +328,9 @@ slapi_pblock_get( Slapi_PBlock *pblock, int arg, void *value )
"Connection is NULL and hence cannot access SLAPI_CONN_IS_REPLICATION_SESSION \n", 0, 0, 0 );
return (-1);
}
- PR_Lock( pblock->pb_conn->c_mutex );
+ PR_EnterMonitor(pblock->pb_conn->c_mutex);
(*(int *)value) = pblock->pb_conn->c_isreplication_session;
- PR_Unlock( pblock->pb_conn->c_mutex );
+ PR_ExitMonitor(pblock->pb_conn->c_mutex);
break;
case SLAPI_CONN_IS_SSL_SESSION:
if (pblock->pb_conn == NULL) {
@@ -338,9 +338,9 @@ slapi_pblock_get( Slapi_PBlock *pblock, int arg, void *value )
"Connection is NULL and hence cannot access SLAPI_CONN_IS_SSL_SESSION \n", 0, 0, 0 );
return (-1);
}
- PR_Lock( pblock->pb_conn->c_mutex );
+ PR_EnterMonitor(pblock->pb_conn->c_mutex);
(*(int *)value) = pblock->pb_conn->c_flags & CONN_FLAG_SSL;
- PR_Unlock( pblock->pb_conn->c_mutex );
+ PR_ExitMonitor(pblock->pb_conn->c_mutex);
break;
case SLAPI_CONN_SASL_SSF:
if (pblock->pb_conn == NULL) {
@@ -348,9 +348,9 @@ slapi_pblock_get( Slapi_PBlock *pblock, int arg, void *value )
"Connection is NULL and hence cannot access SLAPI_CONN_SASL_SSF \n", 0, 0, 0 );
return (-1);
}
- PR_Lock( pblock->pb_conn->c_mutex );
+ PR_EnterMonitor(pblock->pb_conn->c_mutex);
(*(int *)value) = pblock->pb_conn->c_sasl_ssf;
- PR_Unlock( pblock->pb_conn->c_mutex );
+ PR_ExitMonitor(pblock->pb_conn->c_mutex);
break;
case SLAPI_CONN_SSL_SSF:
if (pblock->pb_conn == NULL) {
@@ -358,9 +358,9 @@ slapi_pblock_get( Slapi_PBlock *pblock, int arg, void *value )
"Connection is NULL and hence cannot access SLAPI_CONN_SSL_SSF \n", 0, 0, 0 );
return (-1);
}
- PR_Lock( pblock->pb_conn->c_mutex );
+ PR_EnterMonitor(pblock->pb_conn->c_mutex);
(*(int *)value) = pblock->pb_conn->c_ssl_ssf;
- PR_Unlock( pblock->pb_conn->c_mutex );
+ PR_ExitMonitor(pblock->pb_conn->c_mutex);
break;
case SLAPI_CONN_LOCAL_SSF:
if (pblock->pb_conn == NULL) {
@@ -368,9 +368,9 @@ slapi_pblock_get( Slapi_PBlock *pblock, int arg, void *value )
"Connection is NULL and hence cannot access SLAPI_CONN_LOCAL_SSF \n", 0, 0, 0 );
return (-1);
}
- PR_Lock( pblock->pb_conn->c_mutex );
+ PR_EnterMonitor(pblock->pb_conn->c_mutex);
(*(int *)value) = pblock->pb_conn->c_local_ssf;
- PR_Unlock( pblock->pb_conn->c_mutex );
+ PR_ExitMonitor(pblock->pb_conn->c_mutex);
break;
case SLAPI_CONN_CERT:
if (pblock->pb_conn == NULL) {
@@ -1970,7 +1970,7 @@ slapi_pblock_get( Slapi_PBlock *pblock, int arg, void *value )
int
slapi_pblock_set( Slapi_PBlock *pblock, int arg, void *value )
{
- char *authtype;
+ char *authtype;
PR_ASSERT( NULL != pblock );
@@ -2036,10 +2036,10 @@ slapi_pblock_set( Slapi_PBlock *pblock, int arg, void *value )
"Connection is NULL and hence cannot access SLAPI_CONN_AUTHMETHOD \n", 0, 0, 0 );
return (-1);
}
- PR_Lock( pblock->pb_conn->c_mutex );
- slapi_ch_free((void**)&pblock->pb_conn->c_authtype);
+ PR_EnterMonitor(pblock->pb_conn->c_mutex);
+ slapi_ch_free((void**)&pblock->pb_conn->c_authtype);
pblock->pb_conn->c_authtype = slapi_ch_strdup((char *) value);
- PR_Unlock( pblock->pb_conn->c_mutex );
+ PR_ExitMonitor(pblock->pb_conn->c_mutex);
break;
case SLAPI_CONN_IS_REPLICATION_SESSION:
if (pblock->pb_conn == NULL) {
@@ -2047,9 +2047,9 @@ slapi_pblock_set( Slapi_PBlock *pblock, int arg, void *value )
"Connection is NULL and hence cannot access SLAPI_CONN_IS_REPLICATION_SESSION \n", 0, 0, 0 );
return (-1);
}
- PR_Lock( pblock->pb_conn->c_mutex );
+ PR_EnterMonitor(pblock->pb_conn->c_mutex);
pblock->pb_conn->c_isreplication_session = *((int *) value);
- PR_Unlock( pblock->pb_conn->c_mutex );
+ PR_ExitMonitor(pblock->pb_conn->c_mutex);
break;
/* stuff related to config file processing */
@@ -3565,7 +3565,7 @@ bind_credentials_clear( Connection *conn, PRBool lock_conn,
PRBool clear_externalcreds )
{
if ( lock_conn ) {
- PR_Lock( conn->c_mutex );
+ PR_EnterMonitor(conn->c_mutex);
}
if ( conn->c_dn != NULL ) { /* a non-anonymous bind has occurred */
@@ -3591,7 +3591,7 @@ bind_credentials_clear( Connection *conn, PRBool lock_conn,
}
if ( lock_conn ) {
- PR_Unlock( conn->c_mutex );
+ PR_ExitMonitor(conn->c_mutex);
}
}
@@ -3647,10 +3647,10 @@ void
bind_credentials_set( Connection *conn, char *authtype, char *normdn,
char *extauthtype, char *externaldn, CERTCertificate *clientcert, Slapi_Entry * bind_target_entry )
{
- PR_Lock( conn->c_mutex );
+ PR_EnterMonitor(conn->c_mutex);
bind_credentials_set_nolock(conn, authtype, normdn,
extauthtype, externaldn, clientcert, bind_target_entry);
- PR_Unlock( conn->c_mutex );
+ PR_ExitMonitor(conn->c_mutex);
}
void
diff --git a/ldap/servers/slapd/psearch.c b/ldap/servers/slapd/psearch.c
index b5b4c3a..dcfc07a 100644
--- a/ldap/servers/slapd/psearch.c
+++ b/ldap/servers/slapd/psearch.c
@@ -300,9 +300,9 @@ ps_send_results( void *arg )
/* need to acquire a reference to this connection so that it will not
be released or cleaned up out from under us */
- PR_Lock( ps->ps_pblock->pb_conn->c_mutex );
+ PR_EnterMonitor(ps->ps_pblock->pb_conn->c_mutex);
conn_acq_flag = connection_acquire_nolock(ps->ps_pblock->pb_conn);
- PR_Unlock( ps->ps_pblock->pb_conn->c_mutex );
+ PR_ExitMonitor(ps->ps_pblock->pb_conn->c_mutex);
if (conn_acq_flag) {
slapi_log_error(SLAPI_LOG_CONNS, "Persistent Search",
@@ -419,7 +419,7 @@ ps_send_results( void *arg )
slapi_filter_free(filter, 1);
/* Clean up the connection structure */
- PR_Lock( ps->ps_pblock->pb_conn->c_mutex );
+ PR_EnterMonitor(ps->ps_pblock->pb_conn->c_mutex);
slapi_log_error(SLAPI_LOG_CONNS, "Persistent Search",
"conn=%" NSPRIu64 " op=%d Releasing the connection and operation\n",
@@ -433,7 +433,7 @@ ps_send_results( void *arg )
if (conn_acq_flag == 0) { /* we acquired it, so release it */
connection_release_nolock (ps->ps_pblock->pb_conn);
}
- PR_Unlock( ps->ps_pblock->pb_conn->c_mutex );
+ PR_ExitMonitor(ps->ps_pblock->pb_conn->c_mutex);
PR_DestroyLock ( ps->ps_lock );
ps->ps_lock = NULL;
diff --git a/ldap/servers/slapd/saslbind.c b/ldap/servers/slapd/saslbind.c
index eb814a2..c1e5f2b 100644
--- a/ldap/servers/slapd/saslbind.c
+++ b/ldap/servers/slapd/saslbind.c
@@ -673,7 +673,7 @@ char **ids_sasl_listmech(Slapi_PBlock *pb)
if (sasl_conn == NULL) return ret;
/* sasl library mechanisms are connection dependent */
- PR_Lock(pb->pb_conn->c_mutex);
+ PR_EnterMonitor(pb->pb_conn->c_mutex);
if (sasl_listmech(sasl_conn,
NULL, /* username */
"", ",", "",
@@ -686,7 +686,7 @@ char **ids_sasl_listmech(Slapi_PBlock *pb)
charray_free(others);
slapi_ch_free((void**)&dupstr);
}
- PR_Unlock(pb->pb_conn->c_mutex);
+ PR_ExitMonitor(pb->pb_conn->c_mutex);
LDAPDebug( LDAP_DEBUG_TRACE, "<= ids_sasl_listmech\n", 0, 0, 0 );
@@ -769,13 +769,13 @@ void ids_sasl_check_bind(Slapi_PBlock *pb)
PR_ASSERT(pb);
PR_ASSERT(pb->pb_conn);
- PR_Lock(pb->pb_conn->c_mutex); /* BIG LOCK */
+ PR_EnterMonitor(pb->pb_conn->c_mutex); /* BIG LOCK */
continuing = pb->pb_conn->c_flags & CONN_FLAG_SASL_CONTINUE;
pb->pb_conn->c_flags &= ~CONN_FLAG_SASL_CONTINUE; /* reset flag */
sasl_conn = (sasl_conn_t*)pb->pb_conn->c_sasl_conn;
if (sasl_conn == NULL) {
- PR_Unlock(pb->pb_conn->c_mutex);
+ PR_ExitMonitor(pb->pb_conn->c_mutex); /* BIG LOCK */
send_ldap_result( pb, LDAP_AUTH_METHOD_NOT_SUPPORTED, NULL,
"sasl library unavailable", 0, NULL );
return;
@@ -850,7 +850,7 @@ void ids_sasl_check_bind(Slapi_PBlock *pb)
if (sasl_conn == NULL) {
send_ldap_result( pb, LDAP_AUTH_METHOD_NOT_SUPPORTED, NULL,
"sasl library unavailable", 0, NULL );
- PR_Unlock(pb->pb_conn->c_mutex); /* BIG LOCK */
+ PR_ExitMonitor(pb->pb_conn->c_mutex); /* BIG LOCK */
return;
}
}
@@ -866,7 +866,7 @@ void ids_sasl_check_bind(Slapi_PBlock *pb)
/* retrieve the authenticated username */
if (sasl_getprop(sasl_conn, SASL_USERNAME,
(const void**)&username) != SASL_OK) {
- PR_Unlock(pb->pb_conn->c_mutex); /* BIG LOCK */
+ PR_ExitMonitor(pb->pb_conn->c_mutex); /* BIG LOCK */
send_ldap_result(pb, LDAP_OPERATIONS_ERROR, NULL,
"could not obtain sasl username", 0, NULL);
break;
@@ -887,7 +887,7 @@ void ids_sasl_check_bind(Slapi_PBlock *pb)
}
}
if (dn == NULL) {
- PR_Unlock(pb->pb_conn->c_mutex); /* BIG LOCK */
+ PR_ExitMonitor(pb->pb_conn->c_mutex); /* BIG LOCK */
send_ldap_result(pb, LDAP_OPERATIONS_ERROR, NULL,
"could not get auth dn from sasl", 0, NULL);
break;
@@ -928,7 +928,7 @@ void ids_sasl_check_bind(Slapi_PBlock *pb)
slapi_ch_strdup(normdn),
NULL, NULL, NULL, bind_target_entry);
- PR_Unlock(pb->pb_conn->c_mutex); /* BIG LOCK */
+ PR_ExitMonitor(pb->pb_conn->c_mutex); /* BIG LOCK */
if (plugin_call_plugins( pb, SLAPI_PLUGIN_PRE_BIND_FN ) != 0){
break;
@@ -1003,9 +1003,9 @@ void ids_sasl_check_bind(Slapi_PBlock *pb)
/* see if we negotiated a security layer */
if (*ssfp > 0) {
/* Enable SASL I/O on the connection */
- PR_Lock(pb->pb_conn->c_mutex);
+ PR_EnterMonitor(pb->pb_conn->c_mutex);
connection_set_io_layer_cb(pb->pb_conn, sasl_io_enable, NULL, NULL);
- PR_Unlock(pb->pb_conn->c_mutex);
+ PR_ExitMonitor(pb->pb_conn->c_mutex);
}
/* send successful result */
@@ -1018,7 +1018,7 @@ void ids_sasl_check_bind(Slapi_PBlock *pb)
case SASL_CONTINUE: /* another step needed */
pb->pb_conn->c_flags |= CONN_FLAG_SASL_CONTINUE;
- PR_Unlock(pb->pb_conn->c_mutex); /* BIG LOCK */
+ PR_ExitMonitor(pb->pb_conn->c_mutex); /* BIG LOCK */
if (plugin_call_plugins( pb, SLAPI_PLUGIN_PRE_BIND_FN ) != 0){
break;
@@ -1040,7 +1040,7 @@ void ids_sasl_check_bind(Slapi_PBlock *pb)
case SASL_NOMECH:
- PR_Unlock(pb->pb_conn->c_mutex); /* BIG LOCK */
+ PR_ExitMonitor(pb->pb_conn->c_mutex); /* BIG LOCK */
send_ldap_result(pb, LDAP_AUTH_METHOD_NOT_SUPPORTED, NULL,
"sasl mechanism not supported", 0, NULL);
break;
@@ -1048,7 +1048,7 @@ void ids_sasl_check_bind(Slapi_PBlock *pb)
default: /* other error */
errstr = sasl_errdetail(sasl_conn);
- PR_Unlock(pb->pb_conn->c_mutex); /* BIG LOCK */
+ PR_ExitMonitor(pb->pb_conn->c_mutex); /* BIG LOCK */
send_ldap_result(pb, LDAP_INVALID_CREDENTIALS, NULL,
(char*)errstr, 0, NULL);
break;
diff --git a/ldap/servers/slapd/slap.h b/ldap/servers/slapd/slap.h
index da90fe6..a84e802 100644
--- a/ldap/servers/slapd/slap.h
+++ b/ldap/servers/slapd/slap.h
@@ -1417,7 +1417,7 @@ typedef struct conn {
PRInt32 c_opscompleted; /* # ops completed */
PRInt32 c_threadnumber; /* # threads used in this conn */
int c_refcnt; /* # ops refering to this conn */
- PRLock *c_mutex; /* protect each conn structure */
+ PRMonitor *c_mutex; /* protect each conn structure; need to be re-entrant */
PRLock *c_pdumutex; /* only write one pdu at a time */
time_t c_idlesince; /* last time of activity on conn */
int c_idletimeout; /* local copy of idletimeout */
diff --git a/ldap/servers/slapd/start_tls_extop.c b/ldap/servers/slapd/start_tls_extop.c
index 1efa657..ef492f3 100644
--- a/ldap/servers/slapd/start_tls_extop.c
+++ b/ldap/servers/slapd/start_tls_extop.c
@@ -209,7 +209,7 @@ start_tls( Slapi_PBlock *pb )
/* At least we know that the request was indeed an Start TLS one. */
conn = pb->pb_conn;
- PR_Lock( conn->c_mutex );
+ PR_EnterMonitor(conn->c_mutex);
/* cannot call slapi_send_ldap_result with mutex locked - will deadlock if ber_flush returns error */
#ifndef _WIN32
if ( conn->c_prfd == (PRFileDesc *) NULL ) {
@@ -298,12 +298,12 @@ start_tls( Slapi_PBlock *pb )
/* Since no specific argument for denying the Start TLS request has been found,
* we send a success response back to the client. */
- ldapmsg = "Start TLS request accepted.Server willing to negotiate SSL.";
- unlock_and_return:
- PR_Unlock( conn->c_mutex );
+ ldapmsg = "Start TLS request accepted.Server willing to negotiate SSL.";
+unlock_and_return:
+ PR_ExitMonitor(conn->c_mutex);
slapi_send_ldap_result( pb, ldaprc, NULL, ldapmsg, 0, NULL );
- return( SLAPI_PLUGIN_EXTENDED_SENT_RESULT );
+ return( SLAPI_PLUGIN_EXTENDED_SENT_RESULT );
}/* start_tls */
@@ -368,8 +368,7 @@ start_tls_graceful_closure( Connection *c, Slapi_PBlock * pb, int is_initiator )
*/
}
-
- PR_Lock( c->c_mutex );
+ PR_EnterMonitor(c->c_mutex);
/* "Unimport" the socket from SSL, i.e. get rid of the upper layer of the
* file descriptor stack, which represents SSL.
@@ -409,7 +408,7 @@ start_tls_graceful_closure( Connection *c, Slapi_PBlock * pb, int is_initiator )
bind_credentials_clear( c, PR_FALSE, PR_TRUE );
- PR_Unlock( c->c_mutex );
+ PR_ExitMonitor(c->c_mutex);
diff --git a/ldap/servers/slapd/unbind.c b/ldap/servers/slapd/unbind.c
index afc6069..8800ce4 100644
--- a/ldap/servers/slapd/unbind.c
+++ b/ldap/servers/slapd/unbind.c
@@ -104,9 +104,9 @@ do_unbind( Slapi_PBlock *pb )
}
/* target spec is used to decide which plugins are applicable for the operation */
- PR_Lock( pb->pb_conn->c_mutex );
+ PR_EnterMonitor(pb->pb_conn->c_mutex);
operation_set_target_spec_str (operation, pb->pb_conn->c_dn);
- PR_Unlock( pb->pb_conn->c_mutex );
+ PR_ExitMonitor(pb->pb_conn->c_mutex);
/* ONREPL - plugins should be called and passed bind dn and, possibly, other data */
--
2.4.3