You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@qpid.apache.org by gm...@apache.org on 2018/08/27 15:11:08 UTC

qpid-dispatch git commit: DISPATCH-1103 - Additional fix. Cancel scheduled timer if trying to reschedule same timer

Repository: qpid-dispatch
Updated Branches:
  refs/heads/master c03a9f0ab -> d59ce4172


DISPATCH-1103 - Additional fix. Cancel scheduled timer if trying to reschedule same timer


Project: http://git-wip-us.apache.org/repos/asf/qpid-dispatch/repo
Commit: http://git-wip-us.apache.org/repos/asf/qpid-dispatch/commit/d59ce417
Tree: http://git-wip-us.apache.org/repos/asf/qpid-dispatch/tree/d59ce417
Diff: http://git-wip-us.apache.org/repos/asf/qpid-dispatch/diff/d59ce417

Branch: refs/heads/master
Commit: d59ce4172683414ee7925c20b3da78e1e2227eb0
Parents: c03a9f0
Author: Ganesh Murthy <gm...@redhat.com>
Authored: Mon Aug 27 11:10:52 2018 -0400
Committer: Ganesh Murthy <gm...@redhat.com>
Committed: Mon Aug 27 11:10:52 2018 -0400

----------------------------------------------------------------------
 src/router_core/core_timer.c | 14 ++++++++++----
 1 file changed, 10 insertions(+), 4 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/qpid-dispatch/blob/d59ce417/src/router_core/core_timer.c
----------------------------------------------------------------------
diff --git a/src/router_core/core_timer.c b/src/router_core/core_timer.c
index 0312290..156fe2c 100644
--- a/src/router_core/core_timer.c
+++ b/src/router_core/core_timer.c
@@ -52,6 +52,9 @@ qdr_core_timer_t *qdr_core_timer_CT(qdr_core_t *core, qdr_timer_cb_t callback, v
 
 void qdr_core_timer_schedule_CT(qdr_core_t *core, qdr_core_timer_t *timer, uint32_t delay)
 {
+    if (timer->scheduled)
+        qdr_core_timer_cancel_CT(core, timer);
+
     qdr_core_timer_t *ptr         = DEQ_HEAD(core->scheduled_timers);
     uint32_t          time_before = 0;
 
@@ -105,17 +108,20 @@ void qdr_process_tick_CT(qdr_core_t *core, qdr_action_t *action, bool discard)
         return;
 
     qdr_core_timer_t *timer = DEQ_HEAD(core->scheduled_timers);
+    qdr_core_timer_t *timer_next = 0;
 
     while (timer && timer->delta_time_seconds == 0) {
         assert(timer->scheduled);
+        timer->scheduled = false;
+        timer_next = DEQ_NEXT(timer);
+        DEQ_REMOVE(core->scheduled_timers, timer);
+
         if (timer->handler)
             timer->handler(core, timer->context);
-        timer->scheduled = false;
-        timer = DEQ_NEXT(timer);
-        DEQ_REMOVE_HEAD(core->scheduled_timers);
+
+        timer = timer_next;
     }
 
-    timer = DEQ_HEAD(core->scheduled_timers);
     if (timer)
         timer->delta_time_seconds--;
 }


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@qpid.apache.org
For additional commands, e-mail: commits-help@qpid.apache.org