freetdm: check if the schedule is already running
This commit is contained in:
parent
746e8e44cd
commit
7ef629e34b
|
@ -128,8 +128,16 @@ FT_DECLARE(ftdm_status_t) ftdm_sched_free_run(ftdm_sched_t *sched)
|
||||||
ftdm_status_t status = FTDM_FAIL;
|
ftdm_status_t status = FTDM_FAIL;
|
||||||
ftdm_assert_return(sched != NULL, FTDM_EINVAL, "invalid pointer\n");
|
ftdm_assert_return(sched != NULL, FTDM_EINVAL, "invalid pointer\n");
|
||||||
|
|
||||||
|
ftdm_mutex_lock(sched->mutex);
|
||||||
|
|
||||||
ftdm_mutex_lock(sched_globals.mutex);
|
ftdm_mutex_lock(sched_globals.mutex);
|
||||||
|
|
||||||
|
if (sched->freerun) {
|
||||||
|
ftdm_log(FTDM_LOG_ERROR, "Schedule %s is already running in free run\n", sched->name);
|
||||||
|
goto done;
|
||||||
|
}
|
||||||
|
sched->freerun = 1;
|
||||||
|
|
||||||
if (sched_globals.running == FTDM_FALSE) {
|
if (sched_globals.running == FTDM_FALSE) {
|
||||||
ftdm_log(FTDM_LOG_NOTICE, "Launching main schedule thread\n");
|
ftdm_log(FTDM_LOG_NOTICE, "Launching main schedule thread\n");
|
||||||
status = ftdm_thread_create_detached(run_main_schedule, NULL);
|
status = ftdm_thread_create_detached(run_main_schedule, NULL);
|
||||||
|
@ -154,6 +162,8 @@ FT_DECLARE(ftdm_status_t) ftdm_sched_free_run(ftdm_sched_t *sched)
|
||||||
|
|
||||||
done:
|
done:
|
||||||
ftdm_mutex_unlock(sched_globals.mutex);
|
ftdm_mutex_unlock(sched_globals.mutex);
|
||||||
|
|
||||||
|
ftdm_mutex_unlock(sched->mutex);
|
||||||
return status;
|
return status;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue