]> git.sur5r.net Git - openldap/commitdiff
Initial check of connection states. Have only implemented
authorKurt Zeilenga <kurt@openldap.org>
Tue, 16 Mar 1999 02:59:59 +0000 (02:59 +0000)
committerKurt Zeilenga <kurt@openldap.org>
Tue, 16 Mar 1999 02:59:59 +0000 (02:59 +0000)
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.

servers/slapd/connection.c
servers/slapd/daemon.c
servers/slapd/main.c
servers/slapd/monitor.c
servers/slapd/result.c
servers/slapd/slap.h

index 1d772edcf2740ff67f93fb2980f225049f3a529c..7246a17b2f6199a471734d1c4d1b35420c7e01b1 100644 (file)
@@ -27,7 +27,7 @@ connection_operation( void *arg_v )
        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 );
@@ -87,7 +87,7 @@ connection_operation( void *arg_v )
        }
 
        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;
@@ -191,7 +191,7 @@ connection_activity(
 
        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 ) {
index c58ed25bca93d3a5fa52725010727b7d515b8e20..0b0cfe6b4d9bfca0dd9660bcf7c75a1d6a78fe05 100644 (file)
@@ -83,8 +83,6 @@ slapd_daemon(
                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 );
@@ -168,7 +166,12 @@ slapd_daemon(
 
                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))
@@ -181,6 +184,7 @@ slapd_daemon(
                                    c[i].c_writewaiter ? "w" : "", 0 );
                        }
                }
+
                Debug( LDAP_DEBUG_CONNS, "\n", 0, 0, 0 );
                ldap_pvt_thread_mutex_unlock( &new_conn_mutex );
 
@@ -240,14 +244,6 @@ slapd_daemon(
                                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 );
 
@@ -297,8 +293,6 @@ slapd_daemon(
                                                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;
                        }
@@ -338,9 +332,22 @@ slapd_daemon(
                                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 );
 
index 0d13c4be683e0ac2f15d4c931a5ebf08ab1aa13f..10e14d7fb500c2c19e9e9acd3c2e8445673113a1 100644 (file)
@@ -282,6 +282,8 @@ main( int argc, char **argv )
                            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 ))
index f065df6975767c8e70fc33d6537ec7a2435ae4a6..5554d81c3db567b8f479abf007f539a08f911ca0 100644 (file)
@@ -89,11 +89,14 @@ monitor_info( Connection *conn, Operation *op )
                        ldap_pvt_thread_mutex_unlock( &currenttime_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 );
index e23b518b044cd9f5a10ffcf4e859586599e32099..6d30c29b6d6ee054f4af4bed8534f39eba0a8fba 100644 (file)
@@ -455,6 +455,7 @@ close_connection( Connection *conn, int opconnid, int opid )
                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 );
 }
index b1f6739dc4656f3accd2f13693ba05fa3d79da26..3457eddc804bb44198b10454f039de3c339bb55d 100644 (file)
@@ -411,7 +411,13 @@ typedef struct slap_op {
  * 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  */
@@ -423,7 +429,8 @@ typedef struct slap_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*/
@@ -432,9 +439,13 @@ typedef struct slap_conn {
        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)