LDAP_CIRCLEQ_FOREACH ( c, head, c_next ) {
ldap_pvt_thread_mutex_lock( &c->c_io_mutex );
CONNECTION_LOCK(c);
- if ( c->c_state == SLAP_C_READY && !c->c_pendingber &&
+ if ( c->c_state == LLOAD_C_READY && !c->c_pendingber &&
( b->b_max_conn_pending == 0 ||
c->c_n_ops_executing < b->b_max_conn_pending ) ) {
Debug( LDAP_DEBUG_CONNS, "backend_select: "
avl_dup_error ) ) {
assert(0);
}
- upstream->c_state = SLAP_C_ACTIVE;
+ upstream->c_state = LLOAD_C_ACTIVE;
CONNECTION_UNLOCK(upstream);
ldap_pvt_thread_mutex_unlock( &upstream->c_io_mutex );
client_reset( client );
- client->c_state = SLAP_C_BINDING;
- client->c_type = SLAP_C_OPEN;
+ client->c_state = LLOAD_C_BINDING;
+ client->c_type = LLOAD_C_OPEN;
rc = tavl_insert( &client->c_ops, op, operation_client_cmp, avl_dup_error );
assert( rc == LDAP_SUCCESS );
if ( !--op->o_client_refcnt ) {
operation_destroy_from_client( op );
- if ( client->c_state == SLAP_C_BINDING ) {
- client->c_state = SLAP_C_READY;
- client->c_type = SLAP_C_OPEN;
+ if ( client->c_state == LLOAD_C_BINDING ) {
+ client->c_state = LLOAD_C_READY;
+ client->c_type = LLOAD_C_OPEN;
if ( !BER_BVISNULL( &client->c_auth ) ) {
ber_memfree( client->c_auth.bv_val );
BER_BVZERO( &client->c_auth );
handler = request_extended;
break;
default:
- if ( c->c_state == SLAP_C_BINDING ) {
+ if ( c->c_state == LLOAD_C_BINDING ) {
return operation_send_reject_locked(
op, LDAP_PROTOCOL_ERROR, "bind in progress", 0 );
}
ber_sockbuf_ctrl( c->c_sb, LBER_SB_OPT_SET_MAX_INCOMING, &max );
}
- c->c_state = SLAP_C_READY;
+ c->c_state = LLOAD_C_READY;
event = event_new( base, s, EV_READ|EV_PERSIST, read_cb, c );
if ( !event ) {
c->c_read_event = NULL;
}
- c->c_state = SLAP_C_INVALID;
+ c->c_state = LLOAD_C_INVALID;
CONNECTION_DESTROY(c);
assert( c == NULL );
return NULL;
"destroying client connid=%lu\n",
c->c_connid );
- assert( c->c_state != SLAP_C_INVALID );
+ assert( c->c_state != LLOAD_C_INVALID );
state = c->c_state;
- c->c_state = SLAP_C_INVALID;
+ c->c_state = LLOAD_C_INVALID;
read_event = c->c_read_event;
write_event = c->c_write_event;
event_del( write_event );
}
- if ( state != SLAP_C_CLOSING ) {
+ if ( state != LLOAD_C_CLOSING ) {
ldap_pvt_thread_mutex_lock( &clients_mutex );
LDAP_CIRCLEQ_REMOVE( &clients, c, c_next );
ldap_pvt_thread_mutex_unlock( &clients_mutex );
*/
assert( c->c_refcnt >= 0 );
if ( c->c_refcnt ) {
- c->c_state = SLAP_C_CLOSING;
+ c->c_state = LLOAD_C_CLOSING;
Debug( LDAP_DEBUG_CONNS, "client_destroy: "
"connid=%lu aborting with refcnt=%d\n",
c->c_connid, c->c_refcnt );
lload_features_t lload_features;
-ber_len_t sockbuf_max_incoming_client = SLAP_SB_MAX_INCOMING_CLIENT;
-ber_len_t sockbuf_max_incoming_upstream = SLAP_SB_MAX_INCOMING_UPSTREAM;
+ber_len_t sockbuf_max_incoming_client = LLOAD_SB_MAX_INCOMING_CLIENT;
+ber_len_t sockbuf_max_incoming_upstream = LLOAD_SB_MAX_INCOMING_UPSTREAM;
-int slap_conn_max_pdus_per_cycle = SLAP_CONN_MAX_PDUS_PER_CYCLE_DEFAULT;
+int slap_conn_max_pdus_per_cycle = LLOAD_CONN_MAX_PDUS_PER_CYCLE_DEFAULT;
int slap_write_timeout = 10000;
assert( c->c_live == 0 );
assert( c->c_refcnt == 0 );
- assert( c->c_state == SLAP_C_INVALID );
+ assert( c->c_state == LLOAD_C_INVALID );
ber_sockbuf_free( c->c_sb );
c->c_connid, s, peername );
CONNECTION_LOCK(c);
- c->c_state = SLAP_C_ACTIVE;
+ c->c_state = LLOAD_C_ACTIVE;
return c;
}
}
ber_free( copy, 0 );
- if ( c->c_state == SLAP_C_BINDING ) {
+ if ( c->c_state == LLOAD_C_BINDING ) {
return operation_send_reject_locked(
op, LDAP_PROTOCOL_ERROR, "bind in progress", 0 );
}
* others */
ldap_pvt_thread_mutex_lock( &op->o_mutex );
race_state = op->o_freeing;
- op->o_freeing |= SLAP_OP_FREEING_CLIENT;
+ op->o_freeing |= LLOAD_OP_FREEING_CLIENT;
if ( detach_client ) {
- op->o_freeing |= SLAP_OP_DETACHING_CLIENT;
+ op->o_freeing |= LLOAD_OP_DETACHING_CLIENT;
}
ldap_pvt_thread_mutex_unlock( &op->o_mutex );
"op=%p lost race but client connid=%lu is going down\n",
op, client->c_connid );
CONNECTION_LOCK_DECREF(client);
- } else if ( (race_state & SLAP_OP_FREEING_MASK) ==
- SLAP_OP_FREEING_UPSTREAM ) {
+ } else if ( (race_state & LLOAD_OP_FREEING_MASK) ==
+ LLOAD_OP_FREEING_UPSTREAM ) {
Debug( LDAP_DEBUG_TRACE, "operation_destroy_from_client: "
"op=%p lost race, increased client refcnt connid=%lu "
"to refcnt=%d\n",
/* 5. If we raced the upstream side and won, reclaim the token */
ldap_pvt_thread_mutex_lock( &op->o_link_mutex );
- if ( !(race_state & SLAP_OP_DETACHING_UPSTREAM) ) {
+ if ( !(race_state & LLOAD_OP_DETACHING_UPSTREAM) ) {
upstream = op->o_upstream;
if ( upstream ) {
CONNECTION_LOCK(upstream);
ldap_pvt_thread_mutex_lock( &op->o_mutex );
/* We don't actually resolve the race in full until we grab the other's
* c_mutex+op->o_mutex here */
- if ( upstream && ( op->o_freeing & SLAP_OP_FREEING_UPSTREAM ) ) {
- if ( op->o_freeing & SLAP_OP_DETACHING_UPSTREAM ) {
+ if ( upstream && ( op->o_freeing & LLOAD_OP_FREEING_UPSTREAM ) ) {
+ if ( op->o_freeing & LLOAD_OP_DETACHING_UPSTREAM ) {
CONNECTION_UNLOCK(upstream);
upstream = NULL;
} else {
/* There must have been no race if op is still alive */
ldap_pvt_thread_mutex_lock( &op->o_mutex );
- op->o_freeing &= ~SLAP_OP_FREEING_CLIENT;
+ op->o_freeing &= ~LLOAD_OP_FREEING_CLIENT;
if ( detach_client ) {
- op->o_freeing &= ~SLAP_OP_DETACHING_CLIENT;
+ op->o_freeing &= ~LLOAD_OP_DETACHING_CLIENT;
}
assert( op->o_freeing == 0 );
ldap_pvt_thread_mutex_unlock( &op->o_mutex );
ldap_pvt_thread_mutex_lock( &op->o_mutex );
race_state = op->o_freeing;
- op->o_freeing |= SLAP_OP_FREEING_UPSTREAM;
+ op->o_freeing |= LLOAD_OP_FREEING_UPSTREAM;
if ( detach_upstream ) {
- op->o_freeing |= SLAP_OP_DETACHING_UPSTREAM;
+ op->o_freeing |= LLOAD_OP_DETACHING_UPSTREAM;
}
ldap_pvt_thread_mutex_unlock( &op->o_mutex );
"op=%p lost race but upstream connid=%lu is going down\n",
op, upstream->c_connid );
CONNECTION_LOCK_DECREF(upstream);
- } else if ( (race_state & SLAP_OP_FREEING_MASK) ==
- SLAP_OP_FREEING_CLIENT ) {
+ } else if ( (race_state & LLOAD_OP_FREEING_MASK) ==
+ LLOAD_OP_FREEING_CLIENT ) {
Debug( LDAP_DEBUG_TRACE, "operation_destroy_from_upstream: "
"op=%p lost race, increased upstream refcnt connid=%lu "
"to refcnt=%d\n",
/* 5. If we raced the client side and won, reclaim the token */
ldap_pvt_thread_mutex_lock( &op->o_link_mutex );
- if ( !(race_state & SLAP_OP_DETACHING_CLIENT) ) {
+ if ( !(race_state & LLOAD_OP_DETACHING_CLIENT) ) {
client = op->o_client;
if ( client ) {
CONNECTION_LOCK(client);
/* We don't actually resolve the race in full until we grab the other's
* c_mutex+op->o_mutex here */
ldap_pvt_thread_mutex_lock( &op->o_mutex );
- if ( client && ( op->o_freeing & SLAP_OP_FREEING_CLIENT ) ) {
- if ( op->o_freeing & SLAP_OP_DETACHING_CLIENT ) {
+ if ( client && ( op->o_freeing & LLOAD_OP_FREEING_CLIENT ) ) {
+ if ( op->o_freeing & LLOAD_OP_DETACHING_CLIENT ) {
CONNECTION_UNLOCK(client);
client = NULL;
} else {
op, op->o_client_refcnt );
/* There must have been no race if op is still alive */
ldap_pvt_thread_mutex_lock( &op->o_mutex );
- op->o_freeing &= ~SLAP_OP_FREEING_UPSTREAM;
+ op->o_freeing &= ~LLOAD_OP_FREEING_UPSTREAM;
if ( detach_upstream ) {
- op->o_freeing &= ~SLAP_OP_DETACHING_UPSTREAM;
+ op->o_freeing &= ~LLOAD_OP_DETACHING_UPSTREAM;
}
assert( op->o_freeing == 0 );
ldap_pvt_thread_mutex_unlock( &op->o_mutex );
/* The operation has already been abandoned or finished */
goto unlock;
}
- if ( c->c_state == SLAP_C_BINDING ) {
- c->c_state = SLAP_C_READY;
+ if ( c->c_state == LLOAD_C_BINDING ) {
+ c->c_state = LLOAD_C_READY;
}
c->c_n_ops_executing--;
b = (Backend *)c->c_private;
/* Caller should hold a reference on client */
CONNECTION_LOCK(c);
- if ( c->c_state == SLAP_C_BINDING ) {
- c->c_state = SLAP_C_READY;
+ if ( c->c_state == LLOAD_C_BINDING ) {
+ c->c_state = LLOAD_C_READY;
}
op->o_client_refcnt--;
operation_destroy_from_client( op );
c->c_connid, op->o_client_msgid, slap_msgtype2str( request->o_tag ),
needle.o_client_msgid );
- if ( c->c_state == SLAP_C_BINDING ) {
+ if ( c->c_state == LLOAD_C_BINDING ) {
/* We have found the request and we are binding, it must be a bind
* request */
assert( request->o_tag == LDAP_REQ_BIND );
- c->c_state = SLAP_C_READY;
+ c->c_state = LLOAD_C_READY;
}
CONNECTION_UNLOCK_INCREF(c);
assert( rc == LDAP_SUCCESS );
if ( (lload_features & LLOAD_FEATURE_PROXYAUTHZ) &&
- client->c_type != SLAP_C_PRIVILEGED ) {
+ client->c_type != LLOAD_C_PRIVILEGED ) {
CONNECTION_LOCK_DECREF(client);
Debug( LDAP_DEBUG_TRACE, "request_process: "
"proxying identity %s to upstream\n",
#define SLAP_STRDUP(s) ber_strdup( ( s ) )
#define SLAP_STRNDUP(s, l) ber_strndup( ( s ), ( l ) )
-#define SERVICE_NAME OPENLDAP_PACKAGE "-slapd"
+#define SERVICE_NAME OPENLDAP_PACKAGE "-lloadd"
#define SLAPD_ANONYMOUS ""
#define SLAP_STRING_UNKNOWN "unknown"
#define SLAP_MAX_WORKER_THREADS ( 16 )
-#define SLAP_SB_MAX_INCOMING_CLIENT ( ( 1 << 18 ) - 1 )
-#define SLAP_SB_MAX_INCOMING_UPSTREAM ( ( 1 << 24 ) - 1 )
+#define LLOAD_SB_MAX_INCOMING_CLIENT ( ( 1 << 18 ) - 1 )
+#define LLOAD_SB_MAX_INCOMING_UPSTREAM ( ( 1 << 24 ) - 1 )
-#define SLAP_CONN_MAX_PDUS_PER_CYCLE_DEFAULT 10
+#define LLOAD_CONN_MAX_PDUS_PER_CYCLE_DEFAULT 10
#define SLAP_TEXT_BUFLEN ( 256 )
/* connection state (protected by c_mutex) */
enum sc_state {
- SLAP_C_INVALID = 0, /* MUST BE ZERO (0) */
- SLAP_C_READY, /* ready */
- SLAP_C_CLOSING, /* closing */
- SLAP_C_ACTIVE, /* exclusive operation (tls setup, ...) in progress */
- SLAP_C_BINDING, /* binding */
+ LLOAD_C_INVALID = 0, /* MUST BE ZERO (0) */
+ LLOAD_C_READY, /* ready */
+ LLOAD_C_CLOSING, /* closing */
+ LLOAD_C_ACTIVE, /* exclusive operation (tls setup, ...) in progress */
+ LLOAD_C_BINDING, /* binding */
};
enum sc_type {
- SLAP_C_OPEN = 0, /* regular connection */
- SLAP_C_PREPARING, /* upstream connection not assigned yet */
- SLAP_C_BIND, /* connection used to handle bind client requests if VC not enabled */
- SLAP_C_PRIVILEGED, /* connection can override proxyauthz control */
+ LLOAD_C_OPEN = 0, /* regular connection */
+ LLOAD_C_PREPARING, /* upstream connection not assigned yet */
+ LLOAD_C_BIND, /* connection used to handle bind client requests if VC not enabled */
+ LLOAD_C_PRIVILEGED, /* connection can override proxyauthz control */
};
/*
* represents a connection from an ldap client/to ldap server
};
enum op_state {
- SLAP_OP_NOT_FREEING = 0,
- SLAP_OP_FREEING_UPSTREAM = 1 << 0,
- SLAP_OP_FREEING_CLIENT = 1 << 1,
- SLAP_OP_DETACHING_UPSTREAM = 1 << 2,
- SLAP_OP_DETACHING_CLIENT = 1 << 3,
+ LLOAD_OP_NOT_FREEING = 0,
+ LLOAD_OP_FREEING_UPSTREAM = 1 << 0,
+ LLOAD_OP_FREEING_CLIENT = 1 << 1,
+ LLOAD_OP_DETACHING_UPSTREAM = 1 << 2,
+ LLOAD_OP_DETACHING_CLIENT = 1 << 3,
};
-#define SLAP_OP_FREEING_MASK \
- ( SLAP_OP_FREEING_UPSTREAM | SLAP_OP_FREEING_CLIENT )
-#define SLAP_OP_DETACHING_MASK \
- ( SLAP_OP_DETACHING_UPSTREAM | SLAP_OP_DETACHING_CLIENT )
+#define LLOAD_OP_FREEING_MASK \
+ ( LLOAD_OP_FREEING_UPSTREAM | LLOAD_OP_FREEING_CLIENT )
+#define LLOAD_OP_DETACHING_MASK \
+ ( LLOAD_OP_DETACHING_UPSTREAM | LLOAD_OP_DETACHING_CLIENT )
struct Operation {
Connection *o_client;
CONNECTION_LOCK(upstream);
if ( result != LDAP_SASL_BIND_IN_PROGRESS ) {
- upstream->c_state = SLAP_C_READY;
+ upstream->c_state = LLOAD_C_READY;
}
CONNECTION_UNLOCK(upstream);
CONNECTION_LOCK(client);
- if ( client->c_state == SLAP_C_BINDING ) {
+ if ( client->c_state == LLOAD_C_BINDING ) {
switch ( result ) {
case LDAP_SASL_BIND_IN_PROGRESS:
break;
case LDAP_SUCCESS:
default: {
- client->c_state = SLAP_C_READY;
- client->c_type = SLAP_C_OPEN;
+ client->c_state = LLOAD_C_READY;
+ client->c_type = LLOAD_C_OPEN;
if ( result != LDAP_SUCCESS ) {
ber_memfree( client->c_auth.bv_val );
BER_BVZERO( &client->c_auth );
} else if ( !ber_bvstrcasecmp(
&client->c_auth, &lloadd_identity ) ) {
- client->c_type = SLAP_C_PRIVILEGED;
+ client->c_type = LLOAD_C_PRIVILEGED;
}
if ( !BER_BVISNULL( &client->c_sasl_bind_mech ) ) {
ber_memfree( client->c_sasl_bind_mech.bv_val );
}
}
} else {
- assert( client->c_state == SLAP_C_INVALID ||
- client->c_state == SLAP_C_CLOSING );
+ assert( client->c_state == LLOAD_C_INVALID ||
+ client->c_state == LLOAD_C_CLOSING );
}
CONNECTION_UNLOCK(client);
}
}
- if ( c->c_state == SLAP_C_BINDING ) {
+ if ( c->c_state == LLOAD_C_BINDING ) {
switch ( result ) {
case LDAP_SASL_BIND_IN_PROGRESS:
break;
case LDAP_SUCCESS:
default: {
- c->c_state = SLAP_C_READY;
- c->c_type = SLAP_C_OPEN;
+ c->c_state = LLOAD_C_READY;
+ c->c_type = LLOAD_C_OPEN;
if ( result != LDAP_SUCCESS ) {
ber_memfree( c->c_auth.bv_val );
BER_BVZERO( &c->c_auth );
} else if ( !ber_bvstrcasecmp(
&c->c_auth, &lloadd_identity ) ) {
- c->c_type = SLAP_C_PRIVILEGED;
+ c->c_type = LLOAD_C_PRIVILEGED;
}
if ( !BER_BVISNULL( &c->c_vc_cookie ) ) {
ber_memfree( c->c_vc_cookie.bv_val );
}
}
} else {
- assert( c->c_state == SLAP_C_INVALID || c->c_state == SLAP_C_CLOSING );
+ assert( c->c_state == LLOAD_C_INVALID ||
+ c->c_state == LLOAD_C_CLOSING );
}
CONNECTION_UNLOCK_INCREF(c);
static int
handle_unsolicited( Connection *c, BerElement *ber )
{
- if ( c->c_state == SLAP_C_READY ) {
- c->c_state = SLAP_C_CLOSING;
+ if ( c->c_state == LLOAD_C_READY ) {
+ c->c_state = LLOAD_C_CLOSING;
}
Debug( LDAP_DEBUG_CONNS, "handle_unsolicited: "
CONNECTION_LOCK_DECREF(c);
op->o_upstream_refcnt--;
if ( !client || !op->o_upstream_refcnt ) {
- if ( c->c_state == SLAP_C_BINDING ) {
- c->c_state = SLAP_C_READY;
+ if ( c->c_state == LLOAD_C_BINDING ) {
+ c->c_state = LLOAD_C_READY;
}
operation_destroy_from_upstream( op );
}
switch ( result ) {
case LDAP_SUCCESS: {
c->c_pdu_cb = handle_one_response;
- c->c_state = SLAP_C_READY;
- c->c_type = SLAP_C_OPEN;
+ c->c_state = LLOAD_C_READY;
+ c->c_type = LLOAD_C_OPEN;
CONNECTION_UNLOCK_INCREF(c);
ldap_pvt_thread_mutex_lock( &b->b_mutex );
LDAP_CIRCLEQ_REMOVE( &b->b_preparing, c, c_next );
if ( is_bindconn ) {
LDAP_CIRCLEQ_REMOVE( &b->b_preparing, c, c_next );
LDAP_CIRCLEQ_INSERT_HEAD( &b->b_bindconns, c, c_next );
- c->c_state = SLAP_C_READY;
- c->c_type = SLAP_C_BIND;
+ c->c_state = LLOAD_C_READY;
+ c->c_type = LLOAD_C_BIND;
b->b_bindavail++;
b->b_opening--;
b->b_failed = 0;
} else if ( bindconf.sb_method == LDAP_AUTH_NONE ) {
LDAP_CIRCLEQ_REMOVE( &b->b_preparing, c, c_next );
LDAP_CIRCLEQ_INSERT_HEAD( &b->b_conns, c, c_next );
- c->c_state = SLAP_C_READY;
- c->c_type = SLAP_C_OPEN;
+ c->c_state = LLOAD_C_READY;
+ c->c_type = LLOAD_C_OPEN;
b->b_active++;
b->b_opening--;
b->b_failed = 0;
c->c_pdu_cb = handle_one_response;
LDAP_CIRCLEQ_INSERT_HEAD( &b->b_preparing, c, c_next );
- c->c_type = SLAP_C_PREPARING;
+ c->c_type = LLOAD_C_PREPARING;
{
ber_len_t max = sockbuf_max_incoming_upstream;
event_free( c->c_read_event );
}
- c->c_state = SLAP_C_INVALID;
+ c->c_state = LLOAD_C_INVALID;
CONNECTION_DESTROY(c);
assert( c == NULL );
"freeing connection connid=%lu\n",
c->c_connid );
- assert( c->c_state != SLAP_C_INVALID );
+ assert( c->c_state != LLOAD_C_INVALID );
state = c->c_state;
- c->c_state = SLAP_C_INVALID;
+ c->c_state = LLOAD_C_INVALID;
root = c->c_ops;
c->c_ops = NULL;
}
/* Remove from the backend on first pass */
- if ( state != SLAP_C_CLOSING ) {
+ if ( state != LLOAD_C_CLOSING ) {
ldap_pvt_thread_mutex_lock( &b->b_mutex );
- if ( c->c_type == SLAP_C_PREPARING ) {
+ if ( c->c_type == LLOAD_C_PREPARING ) {
LDAP_CIRCLEQ_REMOVE( &b->b_preparing, c, c_next );
b->b_opening--;
b->b_failed++;
- } else if ( c->c_type == SLAP_C_BIND ) {
+ } else if ( c->c_type == LLOAD_C_BIND ) {
LDAP_CIRCLEQ_REMOVE( &b->b_bindconns, c, c_next );
b->b_bindavail--;
} else {
*/
assert( c->c_refcnt >= 0 );
if ( c->c_refcnt ) {
- c->c_state = SLAP_C_CLOSING;
+ c->c_state = LLOAD_C_CLOSING;
Debug( LDAP_DEBUG_CONNS, "upstream_destroy: "
"connid=%lu aborting with refcnt=%d\n",
c->c_connid, c->c_refcnt );