You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@qpid.apache.org by tr...@apache.org on 2013/04/29 21:48:59 UTC
svn commit: r1477300 - in /qpid/trunk/qpid/extras/dispatch:
include/qpid/dispatch/ctools.h include/qpid/dispatch/timer.h src/timer.c
tests/timer_test.c tests/tool_test.c
Author: tross
Date: Mon Apr 29 19:48:59 2013
New Revision: 1477300
URL: http://svn.apache.org/r1477300
Log:
QPID-4788 - Fixed linked-list corruption when an immediate timer is re-scheduled. Added test.
Modified:
qpid/trunk/qpid/extras/dispatch/include/qpid/dispatch/ctools.h
qpid/trunk/qpid/extras/dispatch/include/qpid/dispatch/timer.h
qpid/trunk/qpid/extras/dispatch/src/timer.c
qpid/trunk/qpid/extras/dispatch/tests/timer_test.c
qpid/trunk/qpid/extras/dispatch/tests/tool_test.c
Modified: qpid/trunk/qpid/extras/dispatch/include/qpid/dispatch/ctools.h
URL: http://svn.apache.org/viewvc/qpid/trunk/qpid/extras/dispatch/include/qpid/dispatch/ctools.h?rev=1477300&r1=1477299&r2=1477300&view=diff
==============================================================================
--- qpid/trunk/qpid/extras/dispatch/include/qpid/dispatch/ctools.h (original)
+++ qpid/trunk/qpid/extras/dispatch/include/qpid/dispatch/ctools.h Mon Apr 29 19:48:59 2013
@@ -117,6 +117,7 @@ do { \
do { \
CT_ASSERT((i)->next == 0); \
CT_ASSERT((i)->prev == 0); \
+ CT_ASSERT(a); \
if ((a)->next) \
(a)->next->prev = (i); \
else \
Modified: qpid/trunk/qpid/extras/dispatch/include/qpid/dispatch/timer.h
URL: http://svn.apache.org/viewvc/qpid/trunk/qpid/extras/dispatch/include/qpid/dispatch/timer.h?rev=1477300&r1=1477299&r2=1477300&view=diff
==============================================================================
--- qpid/trunk/qpid/extras/dispatch/include/qpid/dispatch/timer.h (original)
+++ qpid/trunk/qpid/extras/dispatch/include/qpid/dispatch/timer.h Mon Apr 29 19:48:59 2013
@@ -69,7 +69,7 @@ void dx_timer_free(dx_timer_t *timer);
*
* @param timer Pointer to the timer object returned by dx_timer.
* @param msec The minimum number of milliseconds of delay until the timer fires.
- * If 0 is supplied, the timer will fire immediately.
+ * If 0 is supplied, the timer will be scheduled to fire immediately.
*/
void dx_timer_schedule(dx_timer_t *timer, long msec);
Modified: qpid/trunk/qpid/extras/dispatch/src/timer.c
URL: http://svn.apache.org/viewvc/qpid/trunk/qpid/extras/dispatch/src/timer.c?rev=1477300&r1=1477299&r2=1477300&view=diff
==============================================================================
--- qpid/trunk/qpid/extras/dispatch/src/timer.c (original)
+++ qpid/trunk/qpid/extras/dispatch/src/timer.c Mon Apr 29 19:48:59 2013
@@ -57,6 +57,7 @@ static void dx_timer_cancel_LH(dx_timer_
case TIMER_PENDING:
dx_server_timer_cancel_LH(timer);
+ DEQ_INSERT_TAIL(idle_timers, timer);
break;
}
Modified: qpid/trunk/qpid/extras/dispatch/tests/timer_test.c
URL: http://svn.apache.org/viewvc/qpid/trunk/qpid/extras/dispatch/tests/timer_test.c?rev=1477300&r1=1477299&r2=1477300&view=diff
==============================================================================
--- qpid/trunk/qpid/extras/dispatch/tests/timer_test.c (original)
+++ qpid/trunk/qpid/extras/dispatch/tests/timer_test.c Mon Apr 29 19:48:59 2013
@@ -94,6 +94,30 @@ static char* test_immediate(void *contex
}
+static char* test_immediate_reschedule(void *context)
+{
+ while(fire_head());
+ fire_mask = 0;
+
+ dx_timer_schedule(timers[0], 0);
+ dx_timer_schedule(timers[0], 0);
+
+ if (fire_mask != 0) return "pass 1 - Premature firing";
+ if (fire_head() > 1) return "pass 1 - Too many firings";
+ if (fire_mask != 1) return "pass 1 - Incorrect fire mask";
+
+ fire_mask = 0;
+ dx_timer_schedule(timers[0], 0);
+ dx_timer_schedule(timers[0], 0);
+
+ if (fire_mask != 0) return "pass 2 - Premature firing";
+ if (fire_head() > 1) return "pass 2 - Too many firings";
+ if (fire_mask != 1) return "pass 2 - Incorrect fire mask";
+
+ return 0;
+}
+
+
static char* test_immediate_plus_delayed(void *context)
{
while(fire_head());
@@ -369,6 +393,7 @@ int timer_tests(void)
TEST_CASE(test_quiet, 0);
TEST_CASE(test_immediate, 0);
+ TEST_CASE(test_immediate_reschedule, 0);
TEST_CASE(test_immediate_plus_delayed, 0);
TEST_CASE(test_single, 0);
TEST_CASE(test_two_inorder, 0);
Modified: qpid/trunk/qpid/extras/dispatch/tests/tool_test.c
URL: http://svn.apache.org/viewvc/qpid/trunk/qpid/extras/dispatch/tests/tool_test.c?rev=1477300&r1=1477299&r2=1477300&view=diff
==============================================================================
--- qpid/trunk/qpid/extras/dispatch/tests/tool_test.c (original)
+++ qpid/trunk/qpid/extras/dispatch/tests/tool_test.c Mon Apr 29 19:48:59 2013
@@ -148,11 +148,52 @@ static char* test_deq_basic(void *contex
}
+static char* test_deq_basic2(void *context)
+{
+ item_list_t list;
+ item_t item[10];
+ item_t *ptr;
+ int idx;
+ char *subtest;
+
+ DEQ_INIT(list);
+ if (DEQ_SIZE(list) != 0) return "Expected zero initial size";
+
+ for (idx = 0; idx < 10; idx++) {
+ DEQ_ITEM_INIT(&item[idx]);
+ item[idx].letter = '0' + idx;
+ }
+
+ DEQ_INSERT_TAIL(list, &item[0]);
+ if (DEQ_SIZE(list) != 1) return "Expected 1 items in list";
+ subtest = list_well_formed(list, "0");
+ if (subtest) return subtest;
+
+ ptr = DEQ_HEAD(list);
+ DEQ_REMOVE_HEAD(list);
+ if (ptr->letter != '0') return "Expected item '0'";
+ if (DEQ_SIZE(list) != 0) return "Expected 0 items in list";
+
+ DEQ_INSERT_TAIL(list, &item[0]);
+ if (DEQ_SIZE(list) != 1) return "Expected 1 items in list";
+ subtest = list_well_formed(list, "0");
+ if (subtest) return subtest;
+
+ ptr = DEQ_HEAD(list);
+ DEQ_REMOVE_HEAD(list);
+ if (ptr->letter != '0') return "Expected item '0'";
+ if (DEQ_SIZE(list) != 0) return "Expected 0 items in list";
+
+ return 0;
+}
+
+
int tool_tests(void)
{
int result = 0;
TEST_CASE(test_deq_basic, 0);
+ TEST_CASE(test_deq_basic2, 0);
return result;
}
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@qpid.apache.org
For additional commands, e-mail: commits-help@qpid.apache.org