FS-5661 --resolve

This commit is contained in:
Anthony Minessale 2013-08-07 21:22:26 +05:00
parent 22ab34c507
commit 05444a6ebd
4 changed files with 19 additions and 3 deletions

View File

@ -43,6 +43,7 @@ SWITCH_BEGIN_EXTERN_C
int64_t created;
int64_t runtime;
uint32_t cmd_id;
uint32_t repeat;
char *group;
void *cmd_arg;
uint32_t task_id;

View File

@ -3164,7 +3164,7 @@ SWITCH_STANDARD_API(uuid_broadcast_function)
return SWITCH_STATUS_SUCCESS;
}
#define SCHED_BROADCAST_SYNTAX "[+]<time> <uuid> <path> [aleg|bleg|both]"
#define SCHED_BROADCAST_SYNTAX "[[+]<time>|@time] <uuid> <path> [aleg|bleg|both]"
SWITCH_STANDARD_API(sched_broadcast_function)
{
char *mycmd = NULL, *argv[4] = { 0 };
@ -3180,7 +3180,9 @@ SWITCH_STANDARD_API(sched_broadcast_function)
switch_media_flag_t flags = SMF_NONE;
time_t when;
if (*argv[0] == '+') {
if (*argv[0] == '@') {
when = atol(argv[0] + 1);
} else if (*argv[0] == '+') {
when = switch_epoch_time_now(NULL) + atol(argv[0] + 1);
} else {
when = atol(argv[0]);

View File

@ -1121,7 +1121,9 @@ SWITCH_STANDARD_APP(sched_broadcast_function)
uint32_t id;
char ids[80] = "";
if (*argv[0] == '+') {
if (*argv[0] == '@') {
when = atol(argv[0] + 1);
} else if (*argv[0] == '+') {
when = switch_epoch_time_now(NULL) + atol(argv[0] + 1);
} else {
when = atol(argv[0]);

View File

@ -61,6 +61,10 @@ static void switch_scheduler_execute(switch_scheduler_task_container_t *tp)
tp->func(&tp->task);
if (tp->task.repeat) {
tp->task.runtime = switch_epoch_time_now(NULL) + tp->task.repeat;
}
if (tp->task.runtime > tp->executed) {
tp->executed = 0;
if (switch_event_create(&event, SWITCH_EVENT_RE_SCHEDULE) == SWITCH_STATUS_SUCCESS) {
@ -190,10 +194,17 @@ SWITCH_DECLARE(uint32_t) switch_scheduler_add_task(time_t task_runtime,
{
switch_scheduler_task_container_t *container, *tp;
switch_event_t *event;
switch_time_t now = switch_epoch_time_now(NULL);
switch_mutex_lock(globals.task_mutex);
switch_zmalloc(container, sizeof(*container));
switch_assert(func);
if (task_runtime < now) {
container->task.repeat = task_runtime;
task_runtime += now;
}
container->func = func;
container->task.created = switch_epoch_time_now(NULL);
container->task.runtime = task_runtime;