Commit 7e4b3bc2 authored by Kurt Zeilenga's avatar Kurt Zeilenga
Browse files

initial commit of idletimeout code... everything but the actual timeout.

parent 07e56567
......@@ -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 <integer>
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 <filename>
Read additional configuration information from the given file before
continuing with the next line of the current file.
......
......@@ -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 <seconds>\" 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 <seconds>\" line\n",
fname, lineno, i );
return( 1 );
}
global_idletimeout = i;
/* include another config file */
} else if ( strcasecmp( cargv[0], "include" ) == 0 ) {
if ( cargc < 2 ) {
......
......@@ -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);
......
......@@ -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;
......
......@@ -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;
......
......@@ -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 */
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment