+1998-12-14 Art Cancro Art Cancro <ajc@uncnsrd.mt-kisco.ny.us>
+ * More session table stability nonsense
+
Sun Dec 13 17:40:08 EST 1998 Art Cancro <ajc@uncnsrd.mt-kisco.ny.us>
* sysdep.c, citserver.c: (hopefully) fixed a session table concurrency
bug which was causing the server to occasionally crash.
return;
}
+ lprintf(9, "Locating session to kill\n");
begin_critical_section(S_SESSION_TABLE);
for (ccptr = ContextList; ccptr != NULL; ccptr = ccptr->next) {
if (session_num == ccptr->cs_pid) {
}
}
end_critical_section(S_SESSION_TABLE);
+ lprintf(9, "session_to_kill == %d\n", session_to_kill);
if (session_to_kill > 0) {
kill_session(ccptr->cs_pid);
void terminate_idle_sessions(void) {
struct CitContext *ccptr;
time_t now;
+ int session_to_kill;
-START_OVER:
- now = time(NULL);
- for (ccptr = ContextList; ccptr != NULL; ccptr = ccptr->next) {
- if ( (ccptr!=CC)
- && (config.c_sleeping > 0)
- && (now - (ccptr->lastcmd) > config.c_sleeping) ) {
+ do {
+ now = time(NULL);
+ session_to_kill = 0;
+ lprintf(9, "Scanning for timed out sessions...\n");
+ 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) ) {
+ session_to_kill = ccptr->cs_pid;
+ }
+ }
+ end_critical_section(S_SESSION_TABLE);
+ lprintf(9, "...done scanning.\n");
+ if (session_to_kill > 0) {
lprintf(3, "Session %d timed out. Terminating it...\n",
ccptr->cs_pid);
kill_session(ccptr->cs_pid);
lprintf(9, "...done terminating it.\n");
- goto START_OVER;
}
- }
+ } while(session_to_kill > 0);
}
void kill_session(int session_to_kill) {
struct CitContext *ptr;
+ /* FIX ... do a lock-discover-unlock-kill sequence here. */
for (ptr = ContextList; ptr != NULL; ptr = ptr->next) {
if (ptr->cs_pid == session_to_kill) {
pthread_cancel(ptr->mythread);