SLAP_C_ACTIVE vs SLAP_C_INACTIVE. Need to implement BINDING and CLOSING.
Added fields tracking pending (on bind) ops. Could also be used to
implement per-connection thread limits.
struct co_arg *arg = arg_v;
ldap_pvt_thread_mutex_lock( &arg->co_conn->c_opsmutex );
- arg->co_conn->c_opsinitiated++;
+ arg->co_conn->c_ops_received++;
ldap_pvt_thread_mutex_unlock( &arg->co_conn->c_opsmutex );
ldap_pvt_thread_mutex_lock( &ops_mutex );
}
ldap_pvt_thread_mutex_lock( &arg->co_conn->c_opsmutex );
- arg->co_conn->c_opscompleted++;
+ arg->co_conn->c_ops_completed++;
slap_op_delete( &arg->co_conn->c_ops, arg->co_op );
arg->co_op = NULL;
ldap_pvt_thread_mutex_lock( &conn->c_opsmutex );
arg->co_op = slap_op_add( &conn->c_ops, ber, msgid, tag, tmpdn,
- conn->c_opsinitiated, conn->c_connid );
+ conn->c_ops_received, conn->c_connid );
ldap_pvt_thread_mutex_unlock( &conn->c_opsmutex );
if ( tmpdn != NULL ) {
c[i].c_domain = NULL;
c[i].c_ops = NULL;
lber_pvt_sb_init( &c[i].c_sb );
- c[i].c_writewaiter = 0;
- c[i].c_connid = 0;
ldap_pvt_thread_mutex_init( &c[i].c_dnmutex );
ldap_pvt_thread_mutex_init( &c[i].c_opsmutex );
ldap_pvt_thread_mutex_init( &c[i].c_pdumutex );
ldap_pvt_thread_mutex_lock( &new_conn_mutex );
for ( i = 0; i < dtblsize; i++ ) {
- if ( lber_pvt_sb_in_use( &c[i].c_sb )) {
+ if ( (c[i].c_state != SLAP_C_INACTIVE)
+ && (c[i].c_state != SLAP_C_CLOSING) )
+ {
+#ifdef LDAP_DEBUG
+ assert(lber_pvt_sb_in_use( &c[i].c_sb ));
+#endif
FD_SET( lber_pvt_sb_get_desc(&c[i].c_sb),
&readfds );
if (lber_pvt_sb_data_ready(&c[i].c_sb))
c[i].c_writewaiter ? "w" : "", 0 );
}
}
+
Debug( LDAP_DEBUG_CONNS, "\n", 0, 0, 0 );
ldap_pvt_thread_mutex_unlock( &new_conn_mutex );
continue;
}
- lber_pvt_sb_set_desc( &c[ns].c_sb, ns );
- lber_pvt_sb_set_io( &c[ns].c_sb, &lber_pvt_sb_io_tcp, NULL );
-
- if (lber_pvt_sb_set_nonblock( &c[ns].c_sb, 1)<0) {
- Debug( LDAP_DEBUG_ANY,
- "FIONBIO ioctl on %d failed\n", ns, 0, 0 );
- }
-
Debug( LDAP_DEBUG_CONNS, "new connection on %d\n", ns,
0, 0 );
client_addr == NULL ? "unknown" : client_addr,
0, 0 );
- lber_pvt_sb_close( &c[ns].c_sb );
- lber_pvt_sb_destroy( &c[ns].c_sb );
ldap_pvt_thread_mutex_unlock( &new_conn_mutex );
continue;
}
c[ns].c_cdn = NULL;
}
ldap_pvt_thread_mutex_unlock( &c[ns].c_dnmutex );
+
c[ns].c_starttime = currenttime;
- c[ns].c_opsinitiated = 0;
- c[ns].c_opscompleted = 0;
+ c[ns].c_ops_received = 0;
+ c[ns].c_ops_executing = 0;
+ c[ns].c_ops_pending = 0;
+ c[ns].c_ops_completed = 0;
+
+ lber_pvt_sb_set_desc( &c[ns].c_sb, ns );
+ lber_pvt_sb_set_io( &c[ns].c_sb, &lber_pvt_sb_io_tcp, NULL );
+
+ if (lber_pvt_sb_set_nonblock( &c[ns].c_sb, 1)<0) {
+ Debug( LDAP_DEBUG_ANY,
+ "FIONBIO ioctl on %d failed\n", ns, 0, 0 );
+ }
+
+ c[ns].c_state = SLAP_C_ACTIVE;
}
ldap_pvt_thread_mutex_unlock( &new_conn_mutex );
0, 0, 0 );
}
+ c.c_state = SLAP_C_ACTIVE;
+
ber_init_w_nullc( &ber, 0 );
while ( (tag = ber_get_next( &c.c_sb, &len, &ber ))
ldap_pvt_thread_mutex_unlock( ¤ttime_mutex );
ldap_pvt_thread_mutex_lock( &c[i].c_dnmutex );
- sprintf( buf, "%d : %s : %d : %d : %s : %s%s", i,
- buf2, c[i].c_opsinitiated, c[i].c_opscompleted,
+ sprintf( buf, "%d : %s : %d : %d : %s : %s%s%s%s", i,
+ buf2, c[i].c_ops_received, c[i].c_ops_completed,
c[i].c_cdn ? c[i].c_cdn : "NULLDN",
c[i].c_gettingber ? "r" : "",
- c[i].c_writewaiter ? "w" : "" );
+ c[i].c_writewaiter ? "w" : "",
+ c[i].c_ops_executing ? "x" : "",
+ c[i].c_ops_pending ? "p" : ""
+ );
ldap_pvt_thread_mutex_unlock( &c[i].c_dnmutex );
val.bv_val = buf;
val.bv_len = strlen( buf );
lber_pvt_sb_destroy( &conn->c_sb );
conn->c_version = 0;
conn->c_protocol = 0;
+ conn->c_state = SLAP_C_INACTIVE;
}
ldap_pvt_thread_mutex_unlock( &new_conn_mutex );
}
* represents a connection from an ldap client
*/
+#define SLAP_C_INACTIVE 0x0
+#define SLAP_C_ACTIVE 0x1
+#define SLAP_C_BINDING 0x2
+#define SLAP_C_CLOSING 0x3
+
typedef struct slap_conn {
+ int c_state; /* connection state */
Sockbuf c_sb; /* ber connection stuff */
char *c_cdn; /* DN provided by the client */
char *c_dn; /* DN bound to this conn */
#endif
char *c_addr; /* address of client on this conn */
char *c_domain; /* domain of client on this conn */
- Operation *c_ops; /* list of pending operations */
+ Operation *c_ops; /* list of operations being processed */
+ Operation *c_pending_ops; /* list of pending operations */
ldap_pvt_thread_mutex_t c_opsmutex; /* mutex for c_ops list & stats */
ldap_pvt_thread_mutex_t c_pdumutex; /* only one pdu written at a time */
ldap_pvt_thread_cond_t c_wcv; /* used to wait for sd write-ready*/
int c_writewaiter; /* signals write-ready sd waiter */
int c_pduwaiters; /* signals threads waiting 4 pdu */
time_t c_starttime; /* when the connection was opened */
- int c_connid; /* id of this connection for stats*/
- int c_opsinitiated; /* # ops initiated/next op id */
- int c_opscompleted; /* # ops completed */
+
+ long c_connid; /* id of this connection for stats*/
+
+ long c_ops_received; /* num of ops received (next op_id) */
+ long c_ops_executing; /* num of ops currently executing */
+ long c_ops_pending; /* num of ops pending execution */
+ long c_ops_completed; /* num of ops completed */
} Connection;
#if defined(LDAP_SYSLOG) && defined(LDAP_DEBUG)