Moved terminate_idles_sessions into context.c since it is purely manipulating
authorDave West <davew@uncensored.citadel.org>
Tue, 10 Nov 2009 20:12:04 +0000 (20:12 +0000)
committerDave West <davew@uncensored.citadel.org>
Tue, 10 Nov 2009 20:12:04 +0000 (20:12 +0000)
the context list.

citadel/context.c
citadel/context.h
citadel/housekeeping.c
citadel/housekeeping.h

index bb16d04765e560c5e4d3948cc4dfd788a43bac87..c678829149b0179a51be598c7a5151ebe7c73005 100644 (file)
@@ -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.
  */
index 98d5feb5567eb523b7ee72f4ec92245ca8450b6d..3754a20be3d28e2f005cb7fc835a5fcd34d8d660 100644 (file)
@@ -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 */
index 78e0da5f2d025a5a71983b0c31dc6de17e9a8a4d..5d64012f67767ca11882926dfdfa0f614b96c9d3 100644 (file)
 #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");
index e7048dc5bdd3e5271b2d28d7d51d3b7db98d29f2..8e8affb8baa72648424c0f6c26036cb7f2079f9e 100644 (file)
@@ -1,5 +1,4 @@
 /* $Id$ */
-void terminate_idle_sessions(void);
 void check_sched_shutdown(void);
 void check_ref_counts(void);
 void do_housekeeping(void);