2 * This file contains housekeeping tasks which periodically
20 * Terminate idle sessions. This function pounds through the session table
21 * comparing the current time to each session's time-of-last-command. If an
22 * idle session is found it is terminated, then the search restarts at the
23 * beginning because the pointer to our place in the list becomes invalid.
25 void terminate_idle_sessions(void) {
26 struct CitContext *ccptr;
30 for (ccptr = ContextList; ccptr != NULL; ccptr = ccptr->next) {
32 && (config.c_sleeping > 0)
33 && (now - (ccptr->lastcmd) > config.c_sleeping) ) {
34 lprintf(3, "Session %d timed out\n", ccptr->cs_pid);
35 kill_session(ccptr->cs_pid);
43 * Main housekeeping function.
45 void do_housekeeping() {
47 begin_critical_section(S_HOUSEKEEPING);
49 * Terminate idle sessions.
51 lprintf(7, "Calling terminate_idle_sessions()\n");
52 terminate_idle_sessions();
55 * If the server is scheduled to shut down the next time all
56 * users are logged out, now's the time to do it.
58 if ((ScheduledShutdown == 1) && (ContextList == NULL)) {
59 lprintf(3, "Scheduled shutdown initiating.\n");
62 end_critical_section(S_HOUSEKEEPING);