From: Kurt Zeilenga Date: Fri, 18 Jun 1999 22:54:19 +0000 (+0000) Subject: initial commit of idletimeout code... everything but the actual timeout. X-Git-Tag: OPENLDAP_REL_ENG_2_BP~264 X-Git-Url: https://git.sur5r.net/?a=commitdiff_plain;h=7e4b3bc2e7177ea4ae818ce11ecf2c7d4e266c06;p=openldap initial commit of idletimeout code... everything but the actual timeout. --- diff --git a/doc/man/man5/slapd.conf.5 b/doc/man/man5/slapd.conf.5 index 5fb59fa829..7bca55ba17 100644 --- a/doc/man/man5/slapd.conf.5 +++ b/doc/man/man5/slapd.conf.5 @@ -107,6 +107,11 @@ defaultaccess [self]{ none | compare | search | read | write } Specify the default access to grant requestors not matched by any other access line. The default behavior is to grant read access. .TP +.B idletimeout +Specify the number of seconds to wait before forcibly closing +an idle client connections. A idletimeout of 0 disables this +feature. The default is 0. +.TP .B include Read additional configuration information from the given file before continuing with the next line of the current file. diff --git a/servers/slapd/config.c b/servers/slapd/config.c index 1fc3cf52ea..7147309616 100644 --- a/servers/slapd/config.c +++ b/servers/slapd/config.c @@ -25,6 +25,7 @@ struct acl *global_acl = NULL; int global_default_access = ACL_READ; char *replogfile; int global_lastmod; +int global_idletimeout = 0; char *ldap_srvtab = ""; char *slapd_pid_file = NULL; @@ -508,6 +509,27 @@ read_config( char *fname ) global_lastmod = OFF; } + /* set idle timeout value */ + } else if ( strcasecmp( cargv[0], "idletimeout" ) == 0 ) { + int i; + if ( cargc < 2 ) { + Debug( LDAP_DEBUG_ANY, + "%s: line %d: missing timeout value in \"idletimeout \" line\n", + fname, lineno, 0 ); + return( 1 ); + } + + i = atoi( cargv[1] ); + + if( i < 0 ) { + Debug( LDAP_DEBUG_ANY, + "%s: line %d: timeout value (%d) invalid \"idletimeout \" line\n", + fname, lineno, i ); + return( 1 ); + } + + global_idletimeout = i; + /* include another config file */ } else if ( strcasecmp( cargv[0], "include" ) == 0 ) { if ( cargc < 2 ) { diff --git a/servers/slapd/connection.c b/servers/slapd/connection.c index 1800cc1798..ad6b96c99e 100644 --- a/servers/slapd/connection.c +++ b/servers/slapd/connection.c @@ -212,6 +212,8 @@ static Connection* connection_get( int s ) assert( c->c_struct_state == SLAP_C_USED ); assert( c->c_conn_state != SLAP_C_INVALID ); assert( ber_pvt_sb_in_use( c->c_sb ) ); + + c->c_activitytime = slap_get_time(); } return c; @@ -324,7 +326,7 @@ long connection_init( c->c_n_ops_completed = 0; #endif - c->c_starttime = slap_get_time(); + c->c_activitytime = c->c_starttime = slap_get_time(); ber_pvt_sb_set_desc( c->c_sb, s ); ber_pvt_sb_set_io( c->c_sb, &ber_pvt_sb_io_tcp, NULL ); @@ -362,7 +364,7 @@ connection_destroy( Connection *c ) #endif c->c_protocol = 0; - c->c_starttime = 0; + c->c_activitytime = c->c_starttime = 0; if(c->c_dn != NULL) { free(c->c_dn); diff --git a/servers/slapd/monitor.c b/servers/slapd/monitor.c index c1ee2a993c..b2ea44db1d 100644 --- a/servers/slapd/monitor.c +++ b/servers/slapd/monitor.c @@ -36,6 +36,7 @@ monitor_info( Connection *conn, Operation *op ) #ifdef LDAP_COUNTERS int i; char buf2[22] + char buf3[22] Connection *c; int connindex; #endif @@ -88,19 +89,27 @@ monitor_info( Connection *conn, Operation *op ) #ifndef LDAP_LOCALTIME ltm = gmtime( &c->c_starttime ); strftime( buf2, sizeof(buf2), "%Y%m%d%H%M%SZ", ltm ); + + ltm = gmtime( &c->.c_activitytime ); + strftime( buf3, sizeof(buf2), "%y%m%d%H%M%SZ", ltm ); #else ltm = localtime( &c->.c_starttime ); strftime( buf2, sizeof(buf2), "%y%m%d%H%M%SZ", ltm ); + + ltm = localtime( &c->.c_activitytime ); + strftime( buf3, sizeof(buf2), "%y%m%d%H%M%SZ", ltm ); #endif + ldap_pvt_thread_mutex_unlock( &gmtime_mutex ); - sprintf( buf, "%d : %s : %d : %d : %s : %s%s%s%s", i, + sprintf( buf, "%d : %s : %d : %d : %s : %s%s%s%s : %s", i, buf2, c[i].c_n_ops_received, c[i].c_n_ops_completed, c[i].c_cdn ? c[i].c_cdn : "NULLDN", c[i].c_currentber ? "r" : "", c[i].c_writewaiter ? "w" : "", c[i].c_ops != NULL ? "x" : "", c[i].c_pending_ops != NULL ? "p" : "" + buf3 ); val.bv_val = buf; diff --git a/servers/slapd/proto-slap.h b/servers/slapd/proto-slap.h index 9b7b48ea18..517875c2e8 100644 --- a/servers/slapd/proto-slap.h +++ b/servers/slapd/proto-slap.h @@ -300,6 +300,7 @@ extern int deftime; extern int g_argc; extern int global_default_access; extern int global_lastmod; +extern int global_idletimeout; extern int global_schemacheck; extern int lber_debug; extern int ldap_syslog; diff --git a/servers/slapd/slap.h b/servers/slapd/slap.h index 0b22132604..6c5a3ce7e4 100644 --- a/servers/slapd/slap.h +++ b/servers/slapd/slap.h @@ -509,6 +509,7 @@ typedef struct slap_conn { /* only can be changed by connect_init */ time_t c_starttime; /* when the connection was opened */ + time_t c_activitytime; /* when the connection was last used */ long c_connid; /* id of this connection for stats*/ char *c_client_addr; /* address of client */ char *c_client_name; /* name of client */