]> code.citadel.org Git - citadel.git/commitdiff
Fixed more of the session table nonsense
authorArt Cancro <ajc@citadel.org>
Mon, 14 Dec 1998 23:50:42 +0000 (23:50 +0000)
committerArt Cancro <ajc@citadel.org>
Mon, 14 Dec 1998 23:50:42 +0000 (23:50 +0000)
citadel/citserver.c
citadel/sysdep.c

index 15c6d0c6c1239c439e51b32146844a796d317796..a2aecf5918ebf9cba04203daafaf47dd0fc06cb3 100644 (file)
@@ -572,7 +572,8 @@ void cmd_term(char *cmdbuf)
        lprintf(9, "session_to_kill == %d\n", session_to_kill);
 
        if (session_to_kill > 0) {
-               kill_session(ccptr->cs_pid);
+               lprintf(9, "calling kill_session()\n");
+               kill_session(session_to_kill);
                cprintf("%d Session terminated.\n", OK);
                }
        else {
index 9a05d83cf2bcec5815ce4208ac077ba1ed25245d..d7262d2e2ead075dcc4ea38f5c74cd11e820f5a6 100644 (file)
@@ -479,13 +479,22 @@ void cleanup(int exit_code)
  */
 void kill_session(int session_to_kill) {
        struct CitContext *ptr;
+       THREAD killme = 0;
 
-       /* FIX ... do a lock-discover-unlock-kill sequence here. */
+       lprintf(9, "kill_session() scanning for thread to cancel...\n");
+       begin_critical_section(S_SESSION_TABLE);
        for (ptr = ContextList; ptr != NULL; ptr = ptr->next) {
                if (ptr->cs_pid == session_to_kill) {
-                       pthread_cancel(ptr->mythread);
+                       killme = ptr->mythread;
                        }
                }
+       end_critical_section(S_SESSION_TABLE);
+       lprintf(9, "kill_session() finished scanning.\n");
+
+       if (killme != 0) {
+               lprintf(9, "calling pthread_cancel()\n");
+               pthread_cancel(killme);
+               }
        }