int in_thread;
int destroyed;
int running;
+ int destroy_requested;
switch_scheduler_func_t func;
switch_memory_pool_t *pool;
uint32_t flags;
tp->func(&tp->task);
+ switch_mutex_lock(globals.task_mutex);
if (tp->task.repeat) {
tp->task.runtime = switch_epoch_time_now(NULL) + tp->task.repeat;
}
- if (tp->task.runtime > tp->executed) {
+ if (!tp->destroy_requested && tp->task.runtime > tp->executed) {
tp->executed = 0;
if (switch_event_create(&event, SWITCH_EVENT_RE_SCHEDULE) == SWITCH_STATUS_SUCCESS) {
switch_event_add_header(event, SWITCH_STACK_BOTTOM, "Task-ID", "%u", tp->task.task_id);
} else {
tp->destroyed = 1;
}
+ switch_mutex_unlock(globals.task_mutex);
}
static void *SWITCH_THREAD_FUNC task_own_thread(switch_thread_t *thread, void *obj)
}
if (tp->running) {
- switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "Attempt made to delete running task #%u (group %s)\n",
+ switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, "Attempt made to delete running task #%u (group %s)\n",
tp->task.task_id, tp->task.group);
- break;
+ tp->destroy_requested++;
+ } else {
+ tp->destroyed++;
}
- tp->destroyed++;
delcnt++;
break;
}
tp->task.task_id, group);
continue;
}
- tp->destroyed++;
+ if (tp->running) {
+ switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, "Attempt made to delete running task #%u (group %s)\n",
+ tp->task.task_id, tp->task.group);
+ tp->destroy_requested++;
+ } else {
+ tp->destroyed++;
+ }
delcnt++;
}
}