]> git.ipfire.org Git - thirdparty/freeswitch.git/commitdiff
stop sched thread quicker on global destroy
authorAnthony Minessale <anthm@freeswitch.org>
Mon, 2 Apr 2012 20:33:45 +0000 (15:33 -0500)
committerAnthony Minessale <anthm@freeswitch.org>
Mon, 2 Apr 2012 20:33:45 +0000 (15:33 -0500)
libs/freetdm/src/ftdm_sched.c

index c48c3e9433c9ce64c722f2443f0a7d5935a61d4f..e644067aad747ac26fd8050a9199e75376775b29 100644 (file)
@@ -119,10 +119,15 @@ static void *run_main_schedule(ftdm_thread_t *thread, void *data)
                        /* there are no free runs, wait a bit and check again (FIXME: use ftdm_interrupt_t for this) */
                        ftdm_mutex_unlock(sched_globals.mutex);
 
-                       ftdm_sleep(sleepms);
+                       if (ftdm_running()) {
+                               ftdm_sleep(sleepms);
+                       }
                }
 
                for (current = sched_globals.freeruns; current; current = current->next) {
+                       if (!ftdm_running()) {
+                               break;
+                       }
 
                        /* first run the schedule */
                        ftdm_sched_run(current);
@@ -142,7 +147,9 @@ static void *run_main_schedule(ftdm_thread_t *thread, void *data)
 
                ftdm_mutex_unlock(sched_globals.mutex);
 
-               ftdm_sleep(sleepms);
+               if (ftdm_running()) {
+                       ftdm_sleep(sleepms);
+               }
        }
        ftdm_log(FTDM_LOG_NOTICE, "Main scheduling thread going out ...\n");
        sched_globals.running = 0;