checked_unlock( &b->b_mutex );
*res = LDAP_SUCCESS;
+ CONNECTION_ASSERT_LOCKED(c);
+ assert_locked( &c->c_io_mutex );
return c;
}
CONNECTION_UNLOCK(c);
"shutting down\n" );
return;
}
+ assert_locked( &b->b_mutex );
requested = b->b_numconns;
#ifdef LDAP_API_FEATURE_VERIFY_CREDENTIALS
if ( b->b_active + b->b_bindavail + b->b_opening >= requested ) {
Debug( LDAP_DEBUG_CONNS, "backend_retry: "
"no more connections needed for this backend\n" );
+ assert_locked( &b->b_mutex );
return;
}
Debug( LDAP_DEBUG_CONNS, "backend_retry: "
"retry in progress already\n" );
assert( b->b_opening == 1 );
+ assert_locked( &b->b_mutex );
return;
}
"scheduling a retry in %d ms\n",
b->b_retry_timeout );
event_add( b->b_retry_event, &b->b_retry_tv );
+ assert_locked( &b->b_mutex );
return;
}
b->b_failed++;
event_add( b->b_retry_event, &b->b_retry_tv );
}
+ assert_locked( &b->b_mutex );
}
void
void
backend_reset( LloadBackend *b, int gentle )
{
+ assert_locked( &b->b_mutex );
if ( b->b_cookie ) {
if ( ldap_pvt_thread_pool_retract( b->b_cookie ) ) {
b->b_cookie = NULL;
connections_walk_last( &b->b_mutex, &b->b_conns, b->b_last_conn,
lload_connection_close, &gentle );
assert( gentle || b->b_active == 0 );
+ assert_locked( &b->b_mutex );
}
void
char *ptr, *message = "";
int result = LDAP_SUCCESS;
+ CONNECTION_ASSERT_LOCKED(client);
client->c_state = LLOAD_C_READY;
client->c_type = LLOAD_C_OPEN;
assert( client->c_pin_id == 0 );
goto done;
}
+ assert_locked( &upstream->c_io_mutex );
/*
* At this point, either:
* - upstream is READY and pin == 0
ber_int_t msgid;
int rc;
+ CONNECTION_ASSERT_LOCKED(upstream);
removed = tavl_delete( &upstream->c_ops, op, operation_upstream_cmp );
if ( !removed ) {
assert( upstream->c_state != LLOAD_C_BINDING );
operation_send_reject( op, res, "no connections available", 1 );
goto fail;
}
+ CONNECTION_ASSERT_LOCKED(upstream);
+ assert_locked( &upstream->c_io_mutex );
op->o_upstream = upstream;
op->o_upstream_connid = upstream->c_connid;
op->o_res = LLOAD_OP_FAILED;
TAvlnode *root;
long freed = 0, executing;
+ CONNECTION_ASSERT_LOCKED(c);
root = c->c_ops;
c->c_ops = NULL;
executing = c->c_n_ops_executing;
assert( freed == executing );
CONNECTION_LOCK(c);
+ CONNECTION_ASSERT_LOCKED(c);
}
void
"removing client connid=%lu\n",
c->c_connid );
+ CONNECTION_ASSERT_LOCKED(c);
assert( c->c_state != LLOAD_C_INVALID );
assert( c->c_state != LLOAD_C_DYING );
CONNECTION_LOCK(c);
client_reset( c );
+ CONNECTION_ASSERT_LOCKED(c);
}
void
"destroying connection connid=%lu\n",
c->c_connid );
+ CONNECTION_ASSERT_LOCKED(c);
assert( c->c_live == 0 );
assert( c->c_refcnt == 0 );
assert( c->c_state == LLOAD_C_INVALID );
if ( LDAP_CIRCLEQ_EMPTY( cq ) ) {
return;
}
+ assert_locked( cq_mutex );
+
last_connid = c->c_connid;
c = LDAP_CIRCLEQ_LOOP_NEXT( cq, c, c_next );
while ( !acquire_ref( &c->c_refcnt ) ) {
c = LDAP_CIRCLEQ_LOOP_NEXT( cq, c, c_next );
if ( c->c_connid >= last_connid ) {
+ assert_locked( cq_mutex );
return;
}
}
LloadConnection *old = c;
c = LDAP_CIRCLEQ_LOOP_NEXT( cq, c, c_next );
if ( c->c_connid <= old->c_connid || c->c_connid > last_connid ) {
+ assert_locked( cq_mutex );
return;
}
} while ( !acquire_ref( &c->c_refcnt ) );
} while ( c->c_connid <= last_connid );
+ assert_locked( cq_mutex );
}
void
#define checked_unlock( mutex ) \
if ( ldap_pvt_thread_mutex_unlock( mutex ) != 0 ) assert(0)
+#ifdef LDAP_THREAD_DEBUG
+#define assert_locked( mutex ) \
+ if ( ldap_pvt_thread_mutex_trylock( mutex ) == 0 ) assert(0)
+#else
+#define assert_locked( mutex ) ( (void)0 )
+#endif
+
typedef struct LloadBackend LloadBackend;
typedef struct LloadPendingConnection LloadPendingConnection;
typedef struct LloadConnection LloadConnection;
CONNECTION_DESTROY_CB c_unlink;
CONNECTION_DESTROY_CB c_destroy;
CONNECTION_PDU_CB c_pdu_cb;
+#define CONNECTION_ASSERT_LOCKED(c) assert_locked( &(c)->c_mutex )
#define CONNECTION_LOCK(c) \
do { \
checked_lock( &(c)->c_mutex ); \
goto fail;
}
+ CONNECTION_ASSERT_LOCKED(c);
rc = tavl_insert( &c->c_ops, op, operation_client_cmp, avl_dup_error );
if ( rc ) {
Debug( LDAP_DEBUG_PACKETS, "operation_init: "
static int
handle_unsolicited( LloadConnection *c, BerElement *ber )
{
+ CONNECTION_ASSERT_LOCKED(c);
if ( c->c_state != LLOAD_C_PREPARING ) {
c->c_state = LLOAD_C_CLOSING;
}
LloadBackend *b = c->c_private;
int is_bindconn = 0;
+ assert_locked( &b->b_mutex );
+ CONNECTION_ASSERT_LOCKED(c);
assert( c->c_live );
c->c_pdu_cb = handle_one_response;
Debug( LDAP_DEBUG_CONNS, "upstream_unlink: "
"removing upstream connid=%lu\n",
c->c_connid );
+ CONNECTION_ASSERT_LOCKED(c);
assert( c->c_state != LLOAD_C_INVALID );
assert( c->c_state != LLOAD_C_DYING );
checked_unlock( &b->b_mutex );
CONNECTION_LOCK(c);
+ CONNECTION_ASSERT_LOCKED(c);
}
void