ldap_pvt_thread_mutex_lock( &b->b_lock );
c = b->b_conns;
ldap_pvt_thread_mutex_lock( &c->c_mutex );
- if ( c->c_struct_state != SLAP_C_UNINITIALIZED && !c->c_pendingber ) {
+ if ( c->c_state == SLAP_C_READY && !c->c_pendingber ) {
ldap_pvt_thread_mutex_unlock( &b->b_lock );
return b->b_conns;
}
c = connection_init( s, peername, flags );
+ c->c_state = SLAP_C_READY;
+
event = event_new( base, s, EV_READ|EV_PERSIST, client_read_cb, c );
if ( !event ) {
Debug( LDAP_DEBUG_ANY, "Read event could not be allocated\n" );
event_del( c->c_read_event );
event_free( c->c_read_event );
}
- c->c_struct_state = SLAP_C_UNINITIALIZED;
+ c->c_state = SLAP_C_INVALID;
connection_destroy( c );
return NULL;
}
event_del( c->c_write_event );
event_free( c->c_write_event );
- c->c_struct_state = SLAP_C_UNINITIALIZED;
+ c->c_state = SLAP_C_INVALID;
connection_destroy( c );
}
ARG_INT|ARG_MAGIC|CFG_CONCUR,
&config_generic,
},
- { "backend", "type", 2, 2, 0,
+ { "backend", "type", 2, 0, 0,
ARG_MAGIC|CFG_DATABASE,
&config_backend,
},
"destroying connection %lu.\n",
c->c_connid );
- assert( c->c_struct_state == SLAP_C_UNINITIALIZED );
+ assert( c->c_state == SLAP_C_INVALID );
ber_sockbuf_free( c->c_sb );
if ( c->c_currentber ) {
c->c_connid, s );
ldap_pvt_thread_mutex_lock( &c->c_mutex );
- c->c_struct_state = SLAP_C_USED;
+ c->c_state = SLAP_C_ACTIVE;
return c;
}
LDAP_STAILQ_ENTRY(Backend) b_next;
};
-/*
- * represents a connection from an ldap client
- */
-/* structure state (protected by connections_mutex) */
-enum sc_struct_state {
- SLAP_C_UNINITIALIZED = 0, /* MUST BE ZERO (0) */
- SLAP_C_UNUSED,
- SLAP_C_USED,
- SLAP_C_PENDING
-};
-
/* connection state (protected by c_mutex) */
-enum sc_conn_state {
+enum sc_state {
SLAP_C_INVALID = 0, /* MUST BE ZERO (0) */
- SLAP_C_INACTIVE, /* zero threads */
+ SLAP_C_READY, /* ready */
SLAP_C_CLOSING, /* closing */
- SLAP_C_ACTIVE, /* one or more threads */
+ SLAP_C_ACTIVE, /* exclusive operation (tls setup, ...) in progress */
SLAP_C_BINDING, /* binding */
- SLAP_C_CLIENT /* outbound client conn */
};
+/*
+ * represents a connection from an ldap client/to ldap server
+ */
struct Connection {
- enum sc_struct_state c_struct_state; /* structure management state */
- enum sc_conn_state c_conn_state; /* connection state */
+ enum sc_state c_state; /* connection state */
ber_socket_t c_fd;
ldap_pvt_thread_mutex_t c_mutex; /* protect the connection */
c->c_write_event = event;
c->c_private = backend;
+
+ c->c_state = SLAP_C_READY;
ldap_pvt_thread_mutex_unlock( &c->c_mutex );
return c;
{
Backend *b = c->c_private;
- c->c_struct_state = SLAP_C_UNINITIALIZED;
+ c->c_state = SLAP_C_INVALID;
ldap_pvt_thread_mutex_unlock( &c->c_mutex );
ldap_pvt_thread_mutex_lock( &b->b_lock );