Don't queue up all the worker threads waiting for the session table in
authorDave West <davew@uncensored.citadel.org>
Fri, 30 Nov 2007 19:47:29 +0000 (19:47 +0000)
committerDave West <davew@uncensored.citadel.org>
Fri, 30 Nov 2007 19:47:29 +0000 (19:47 +0000)
dead_session_purge(). If it is locked just get out. If that leaves a
dead session/context or two lying around then no biggie because the next
time through will clean them.

citadel/sysdep.c

index dcd3b249f78a8606353c32b3c8e3f586495b9ee9..b16e2d37245c0ac82734572dc2af2ad727e739ce 100644 (file)
@@ -1810,17 +1810,16 @@ void dead_session_purge(int force) {
        struct CitContext *ptr, *ptr2;          /* general-purpose utility pointer */
        struct CitContext *rem = NULL;  /* list of sessions to be destroyed */
        
-       CtdlThreadPushName("dead_session_purge");
-       
        if (force == 0) {
                if ( (time(NULL) - last_purge) < 5 ) {
-                       CtdlThreadPopName();
                        return; /* Too soon, go away */
                }
        }
        time(&last_purge);
 
-       begin_critical_section(S_SESSION_TABLE);
+       if (try_critical_section(S_SESSION_TABLE))
+               return;
+               
        ptr = ContextList;
        while (ptr) {
                ptr2 = ptr;
@@ -1839,11 +1838,9 @@ void dead_session_purge(int force) {
                        }
 
                        --num_sessions;
-
                        /* And put it on our to-be-destroyed list */
                        ptr2->next = rem;
                        rem = ptr2;
-
                }
        }
        end_critical_section(S_SESSION_TABLE);
@@ -1972,7 +1969,6 @@ do_select:        force_purge = 0;
                        tv.tv_sec = 1;          /* wake up every second if no input */
                        tv.tv_usec = 0;
                        retval = CtdlThreadSelect(highest + 1, &readfds, NULL, NULL, &tv, CT);
-//                     retval = select(highest + 1, &readfds, NULL, NULL, &tv);
                }
 
                if (CtdlThreadCheckStop(CT)) return(NULL);