From: Dave West Date: Tue, 10 Nov 2009 20:12:04 +0000 (+0000) Subject: Moved terminate_idles_sessions into context.c since it is purely manipulating X-Git-Tag: v7.86~631 X-Git-Url: https://code.citadel.org/?p=citadel.git;a=commitdiff_plain;h=390901bcc3d171cc42fe259d8a8e55687efbdf4f Moved terminate_idles_sessions into context.c since it is purely manipulating the context list. --- diff --git a/citadel/context.c b/citadel/context.c index bb16d0476..c67882914 100644 --- a/citadel/context.c +++ b/citadel/context.c @@ -222,6 +222,44 @@ CitContext *MyContext(void) { +/* + * Terminate idle sessions. This function pounds through the session table + * comparing the current time to each session's time-of-last-command. If an + * idle session is found it is terminated, then the search restarts at the + * beginning because the pointer to our place in the list becomes invalid. + */ +void terminate_idle_sessions(void) +{ + CitContext *ccptr; + time_t now; + int session_to_kill; + int killed = 0; + int longrunners = 0; + + now = time(NULL); + session_to_kill = 0; + begin_critical_section(S_SESSION_TABLE); + for (ccptr = ContextList; ccptr != NULL; ccptr = ccptr->next) { + if ( (ccptr!=CC) + && (config.c_sleeping > 0) + && (now - (ccptr->lastcmd) > config.c_sleeping) ) { + if (!ccptr->dont_term) { + ccptr->kill_me = 1; + ++killed; + } + else + longrunners ++; + } + } + end_critical_section(S_SESSION_TABLE); + if (killed > 0) + CtdlLogPrintf(CTDL_INFO, "Terminated %d idle sessions\n", killed); + if (longrunners > 0) + CtdlLogPrintf(CTDL_INFO, "Didn't terminate %d protected idle sessions;\n", killed); +} + + + /* * Terminate a session. */ diff --git a/citadel/context.h b/citadel/context.h index 98d5feb55..3754a20be 100644 --- a/citadel/context.h +++ b/citadel/context.h @@ -149,5 +149,6 @@ void dead_session_purge(int force); /* Deprecated, user CtdlBumpNewMailCounter() instead */ void BumpNewMailCounter(long) __attribute__ ((deprecated)); +void terminate_idle_sessions(void); #endif /* CONTEXT_H */ diff --git a/citadel/housekeeping.c b/citadel/housekeeping.c index 78e0da5f2..5d64012f6 100644 --- a/citadel/housekeeping.c +++ b/citadel/housekeeping.c @@ -46,43 +46,6 @@ #include "ctdl_module.h" #include "threads.h" -/* - * Terminate idle sessions. This function pounds through the session table - * comparing the current time to each session's time-of-last-command. If an - * idle session is found it is terminated, then the search restarts at the - * beginning because the pointer to our place in the list becomes invalid. - */ -void terminate_idle_sessions(void) { - CitContext *ccptr; - time_t now; - int session_to_kill; - int killed = 0; - int longrunners = 0; - - now = time(NULL); - session_to_kill = 0; - begin_critical_section(S_SESSION_TABLE); - for (ccptr = ContextList; ccptr != NULL; ccptr = ccptr->next) { - if ( (ccptr!=CC) - && (config.c_sleeping > 0) - && (now - (ccptr->lastcmd) > config.c_sleeping) ) { - if (!ccptr->dont_term) { - ccptr->kill_me = 1; - ++killed; - } - else - longrunners ++; - } - } - end_critical_section(S_SESSION_TABLE); - if (killed > 0) - CtdlLogPrintf(CTDL_INFO, "Terminated %d idle sessions\n", killed); - if (longrunners > 0) - CtdlLogPrintf(CTDL_INFO, "Didn't terminate %d protected idle sessions;\n", killed); -} - - - void check_sched_shutdown(void) { if ((ScheduledShutdown == 1) && (ContextList == NULL)) { CtdlLogPrintf(CTDL_NOTICE, "Scheduled shutdown initiating.\n"); diff --git a/citadel/housekeeping.h b/citadel/housekeeping.h index e7048dc5b..8e8affb8b 100644 --- a/citadel/housekeeping.h +++ b/citadel/housekeeping.h @@ -1,5 +1,4 @@ /* $Id$ */ -void terminate_idle_sessions(void); void check_sched_shutdown(void); void check_ref_counts(void); void do_housekeeping(void);