c->c_peer_name = NULL;
c->c_sock_name = NULL;
- c->c_ops = NULL;
- c->c_pending_ops = NULL;
+ STAILQ_INIT(&c->c_ops);
+ STAILQ_INIT(&c->c_pending_ops);
c->c_sasl_bind_mech = NULL;
c->c_sasl_context = NULL;
assert( c->c_peer_domain == NULL );
assert( c->c_peer_name == NULL );
assert( c->c_sock_name == NULL );
- assert( c->c_ops == NULL );
- assert( c->c_pending_ops == NULL );
+ assert( STAILQ_EMPTY(&c->c_ops) );
+ assert( STAILQ_EMPTY(&c->c_pending_ops) );
assert( c->c_sasl_bind_mech == NULL );
assert( c->c_sasl_context == NULL );
assert( c->c_sasl_extra == NULL );
assert( c != NULL );
assert( c->c_struct_state != SLAP_C_UNUSED );
assert( c->c_conn_state != SLAP_C_INVALID );
- assert( c->c_ops == NULL );
+ assert( STAILQ_EMPTY(&c->c_ops) );
backend_connection_destroy(c);
Operation *o;
- for( o = c->c_ops; o != NULL; o = o->o_next ) {
+ STAILQ_FOREACH(o, &c->c_ops, o_next) {
ldap_pvt_thread_mutex_lock( &o->o_abandonmutex );
o->o_abandon = 1;
ldap_pvt_thread_mutex_unlock( &o->o_abandonmutex );
}
/* remove pending operations */
- for( o = slap_op_pop( &c->c_pending_ops );
- o != NULL;
- o = slap_op_pop( &c->c_pending_ops ) )
- {
+ while ( (o = STAILQ_FIRST( &c->c_pending_ops )) != NULL) {
+ STAILQ_REMOVE_HEAD( &c->c_pending_ops, o_next );
+ STAILQ_NEXT(o, o_next) = NULL;
slap_op_free( o );
}
}
/* note: connections_mutex and c_mutex should be locked by caller */
ber_sockbuf_ctrl( c->c_sb, LBER_SB_OPT_GET_FD, &sd );
- if( c->c_ops != NULL ) {
+ if( !STAILQ_EMPTY(&c->c_ops) ) {
#ifdef NEW_LOGGING
LDAP_LOG(( "connection", LDAP_LEVEL_DETAIL1,
"connection_close: conn %d deferring sd %d\n",
conn->c_n_ops_executing--;
conn->c_n_ops_completed++;
- slap_op_remove( &conn->c_ops, arg->co_op );
+ STAILQ_REMOVE( &conn->c_ops, arg->co_op, slap_op, o_next);
+ STAILQ_NEXT(arg->co_op, o_next) = NULL;
slap_op_free( arg->co_op );
arg->co_op = NULL;
arg->co_conn = NULL;
Debug( LDAP_DEBUG_ANY, "deferring operation\n", 0, 0, 0 );
#endif
conn->c_n_ops_pending++;
- slap_op_add( &conn->c_pending_ops, op );
+ STAILQ_INSERT_TAIL( &conn->c_pending_ops, op, o_next );
} else {
conn->c_n_ops_executing++;
return 0;
}
- for( op = slap_op_pop( &conn->c_pending_ops );
- op != NULL;
- op = slap_op_pop( &conn->c_pending_ops ) )
- {
+ while ((op = STAILQ_FIRST( &conn->c_pending_ops )) != NULL) {
+ STAILQ_REMOVE_HEAD( &conn->c_pending_ops, o_next );
+ STAILQ_NEXT(op, o_next) = NULL;
/* pending operations should not be marked for abandonment */
assert(!op->o_abandon);
}
arg->co_op->o_connid = conn->c_connid;
- slap_op_add( &conn->c_ops, arg->co_op );
+ STAILQ_INSERT_TAIL( &conn->c_ops, arg->co_op, o_next );
status = ldap_pvt_thread_pool_submit( &connection_pool,
connection_operation, (void *) arg );
op->o_protocol = LDAP_VERSION3;
(*conn) = connection_get( fd[1] );
- (*conn)->c_ops = op;
- (*conn)->c_conn_state = SLAP_C_ACTIVE;
-
+ STAILQ_INSERT_HEAD( &(*conn)->c_ops, op, o_next);
+ (*conn)->c_conn_state = SLAP_C_ACTIVE;
/* Create the client side of the connection */
rc = ldap_open_internal_connection( ldp, &(fd[0]) );
void connection_internal_close( Connection *conn )
{
- Operation *op = conn->c_ops;
+ Operation *op = STAILQ_FIRST(&conn->c_ops);
- slap_op_remove( &conn->c_ops, op );
+ STAILQ_REMOVE_HEAD(&conn->c_ops, o_next);
+ STAILQ_NEXT(op, o_next) = NULL;
slap_op_free( op );
connection_closing( conn );
connection_close( conn );
if( rc != LDAP_SUCCESS )
goto FINISHED;
- (*be->be_search)( be, conn, conn->c_ops, /*base*/NULL, &searchbase,
+ (*be->be_search)( be, conn, STAILQ_FIRST(&conn->c_ops), /*base*/NULL, &searchbase,
scope, /*deref=*/1, /*sizelimit=*/1, /*time=*/0, filter, /*fstr=*/NULL,
/*attrs=*/NULL, /*attrsonly=*/0 );
if( rc != LDAP_SUCCESS )
goto CONCLUDED;
- (*be->be_search)( be, conn, conn->c_ops, /*base=*/NULL, &searchbase,
+ (*be->be_search)( be, conn, STAILQ_FIRST(&conn->c_ops), /*base=*/NULL, &searchbase,
scope, /*deref=*/1, /*sizelimit=*/0, /*time=*/0, filter, /*fstr=*/NULL,
/*attrs=*/NULL, /*attrsonly=*/0 );
#include <ldap_schema.h>
#include "ldap_pvt_thread.h"
+#include "queue-compat.h"
LDAP_BEGIN_DECL
slap_response *o_response; /* callback function */
slap_sresult *o_sresult; /* search result callback */
- struct slap_op *o_next; /* next operation in list */
+ STAILQ_ENTRY(slap_op) o_next; /* next operation in list */
void *o_private; /* anything the backend needs */
void *o_glue; /* for the glue backend */
} Operation;
ber_int_t c_protocol; /* version of the LDAP protocol used by client */
- Operation *c_ops; /* list of operations being processed */
- Operation *c_pending_ops; /* list of pending operations */
+ STAILQ_HEAD(c_o, slap_op) c_ops; /* list of operations being processed */
+ STAILQ_HEAD(c_po, slap_op) c_pending_ops; /* list of pending operations */
ldap_pvt_thread_mutex_t c_write_mutex; /* only one pdu written at a time */
ldap_pvt_thread_cond_t c_write_cv; /* used to wait for sd write-ready*/