More session table stability nonsense
authorArt Cancro <ajc@citadel.org>
Mon, 14 Dec 1998 23:23:58 +0000 (23:23 +0000)
committerArt Cancro <ajc@citadel.org>
Mon, 14 Dec 1998 23:23:58 +0000 (23:23 +0000)
citadel/ChangeLog
citadel/citserver.c
citadel/housekeeping.c
citadel/sysdep.c

index 3a4f06195e10ffa8e3c373109863fc9beabb25f1..f5d1b240e46f8bff0963151d6a66115e2fc04ded 100644 (file)
@@ -1,3 +1,6 @@
+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.
index 846fb071215974d4be07e55542b1c477a28df0a3..15c6d0c6c1239c439e51b32146844a796d317796 100644 (file)
@@ -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);
index e8c060c7bf0d075fa0e075fc81f02a332ea111b4..8ede483c6497f60dabba23c9da7e68f4329aaccf 100644 (file)
 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);
        }
 
 
index 57fae4f48822dadb47853066be9aa16c9d12598f..9a05d83cf2bcec5815ce4208ac077ba1ed25245d 100644 (file)
@@ -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);