From: Art Cancro Date: Mon, 14 Dec 1998 23:23:58 +0000 (+0000) Subject: More session table stability nonsense X-Git-Tag: v7.86~8008 X-Git-Url: https://code.citadel.org/?p=citadel.git;a=commitdiff_plain;h=098337ce1d9d2c29e8e824fd8d2d650226c91138 More session table stability nonsense --- diff --git a/citadel/ChangeLog b/citadel/ChangeLog index 3a4f06195..f5d1b240e 100644 --- a/citadel/ChangeLog +++ b/citadel/ChangeLog @@ -1,3 +1,6 @@ +1998-12-14 Art Cancro Art Cancro + * More session table stability nonsense + Sun Dec 13 17:40:08 EST 1998 Art Cancro * sysdep.c, citserver.c: (hopefully) fixed a session table concurrency bug which was causing the server to occasionally crash. diff --git a/citadel/citserver.c b/citadel/citserver.c index 846fb0712..15c6d0c6c 100644 --- a/citadel/citserver.c +++ b/citadel/citserver.c @@ -561,6 +561,7 @@ void cmd_term(char *cmdbuf) 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) { @@ -568,6 +569,7 @@ void cmd_term(char *cmdbuf) } } 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); diff --git a/citadel/housekeeping.c b/citadel/housekeeping.c index e8c060c7b..8ede483c6 100644 --- a/citadel/housekeeping.c +++ b/citadel/housekeeping.c @@ -31,20 +31,29 @@ 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); } diff --git a/citadel/sysdep.c b/citadel/sysdep.c index 57fae4f48..9a05d83cf 100644 --- a/citadel/sysdep.c +++ b/citadel/sysdep.c @@ -480,6 +480,7 @@ void cleanup(int exit_code) 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);