Allow simulation mode to be terminated before completion
authorDave West <davew@uncensored.citadel.org>
Mon, 2 Nov 2009 14:01:47 +0000 (14:01 +0000)
committerDave West <davew@uncensored.citadel.org>
Mon, 2 Nov 2009 14:01:47 +0000 (14:01 +0000)
citadel/threads.c

index aa6636e0aa3c720a2a7d173ed57884a455c4c33e..5f4de7bbdd85ac8b28ba5a49cdf635be8a331de4 100644 (file)
@@ -1238,6 +1238,7 @@ void *simulation_worker (void*arg) {
        struct CitContext *this;
 
        this = CreateNewContext();
+       CtdlThreadSleep(1);
        this->kill_me = 1;
        this->state = CON_IDLE;
        dead_session_purge(1);
@@ -1252,7 +1253,7 @@ void *simulation_thread (void *arg)
 {
        long stats = statcount;
 
-       while(stats) {
+       while(stats && !CtdlThreadCheckStop()) {
                CtdlThreadCreate("Connection simulation worker", CTDLTHREAD_BIGSTACK, simulation_worker, NULL);
                stats--;
        }
@@ -1390,7 +1391,7 @@ void go_threading(void)
 #ifdef THREADS_USESIGNALS
                if (CtdlThreadGetCount() && CT->state > CTDL_THREAD_STOP_REQ)
 #else
-               if (CtdlThreadGetCount() && !statcount)
+               if (CtdlThreadGetCount())
 #endif
                        CtdlThreadSleep(1);
        }