Skip to content

Commit 116ebc0

Browse files
committed
FS-5661 --resolve
1 parent 11d6c08 commit 116ebc0

File tree

4 files changed

+19
-3
lines changed

4 files changed

+19
-3
lines changed

src/include/switch_scheduler.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ SWITCH_BEGIN_EXTERN_C
4343
int64_t created;
4444
int64_t runtime;
4545
uint32_t cmd_id;
46+
uint32_t repeat;
4647
char *group;
4748
void *cmd_arg;
4849
uint32_t task_id;

src/mod/applications/mod_commands/mod_commands.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3164,7 +3164,7 @@ SWITCH_STANDARD_API(uuid_broadcast_function)
31643164
return SWITCH_STATUS_SUCCESS;
31653165
}
31663166

3167-
#define SCHED_BROADCAST_SYNTAX "[+]<time> <uuid> <path> [aleg|bleg|both]"
3167+
#define SCHED_BROADCAST_SYNTAX "[[+]<time>|@time] <uuid> <path> [aleg|bleg|both]"
31683168
SWITCH_STANDARD_API(sched_broadcast_function)
31693169
{
31703170
char *mycmd = NULL, *argv[4] = { 0 };
@@ -3180,7 +3180,9 @@ SWITCH_STANDARD_API(sched_broadcast_function)
31803180
switch_media_flag_t flags = SMF_NONE;
31813181
time_t when;
31823182

3183-
if (*argv[0] == '+') {
3183+
if (*argv[0] == '@') {
3184+
when = atol(argv[0] + 1);
3185+
} else if (*argv[0] == '+') {
31843186
when = switch_epoch_time_now(NULL) + atol(argv[0] + 1);
31853187
} else {
31863188
when = atol(argv[0]);

src/mod/applications/mod_dptools/mod_dptools.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1121,7 +1121,9 @@ SWITCH_STANDARD_APP(sched_broadcast_function)
11211121
uint32_t id;
11221122
char ids[80] = "";
11231123

1124-
if (*argv[0] == '+') {
1124+
if (*argv[0] == '@') {
1125+
when = atol(argv[0] + 1);
1126+
} else if (*argv[0] == '+') {
11251127
when = switch_epoch_time_now(NULL) + atol(argv[0] + 1);
11261128
} else {
11271129
when = atol(argv[0]);

src/switch_scheduler.c

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,10 @@ static void switch_scheduler_execute(switch_scheduler_task_container_t *tp)
6161

6262
tp->func(&tp->task);
6363

64+
if (tp->task.repeat) {
65+
tp->task.runtime = switch_epoch_time_now(NULL) + tp->task.repeat;
66+
}
67+
6468
if (tp->task.runtime > tp->executed) {
6569
tp->executed = 0;
6670
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,
190194
{
191195
switch_scheduler_task_container_t *container, *tp;
192196
switch_event_t *event;
197+
switch_time_t now = switch_epoch_time_now(NULL);
193198

194199
switch_mutex_lock(globals.task_mutex);
195200
switch_zmalloc(container, sizeof(*container));
196201
switch_assert(func);
202+
203+
if (task_runtime < now) {
204+
container->task.repeat = task_runtime;
205+
task_runtime += now;
206+
}
207+
197208
container->func = func;
198209
container->task.created = switch_epoch_time_now(NULL);
199210
container->task.runtime = task_runtime;

0 commit comments

Comments
 (0)