]> git.ipfire.org Git - thirdparty/freeswitch.git/commitdiff
FS-5661 --resolve
authorAnthony Minessale <anthm@freeswitch.org>
Wed, 7 Aug 2013 16:22:26 +0000 (21:22 +0500)
committerAnthony Minessale <anthm@freeswitch.org>
Wed, 7 Aug 2013 16:22:26 +0000 (21:22 +0500)
src/include/switch_scheduler.h
src/mod/applications/mod_commands/mod_commands.c
src/mod/applications/mod_dptools/mod_dptools.c
src/switch_scheduler.c

index 8d9bd9ca1aa567d3c58b3b0d26501a465ecd7041..59997a006d8277a1639a5c9ad087b00459b8f251 100644 (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;
index ef91f36a8d6bf3dc5378625bbfd03892ea7eb076..fc74c3dd65f39621dae2d45d1bd6a9138b82e59c 100644 (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]);
index ede2d5f742382e8a2f02dbe337c92042095a1247..1f910c70ab605d0c6f9d5cb4916345c2289c7a8a 100755 (executable)
@@ -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]);
index 056d952242973109345e081b0cdf9a2a7153c6e3..b71821e2983acff6947f019cdc3e2578a36297a8 100644 (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;