diff options
author | Steve Huston <shuston@riverace.com> | 2006-03-16 22:32:09 +0000 |
---|---|---|
committer | Steve Huston <shuston@riverace.com> | 2006-03-16 22:32:09 +0000 |
commit | 323e40046c0e3ed05f963d3672f7b6cabd671b8e (patch) | |
tree | 87d15caad8ee440733f49f77967c393314480ad2 | |
parent | 05ac302793162a95f64481b340fb4ca4c041273f (diff) | |
download | ATCD-323e40046c0e3ed05f963d3672f7b6cabd671b8e.tar.gz |
ChangeLogTag:Thu Mar 16 21:54:29 UTC 2006 Steve Huston <shuston@riverace.com>
-rw-r--r-- | ChangeLog | 17 | ||||
-rw-r--r-- | THANKS | 1 | ||||
-rw-r--r-- | ace/Timer_Heap_T.cpp | 3 | ||||
-rw-r--r-- | tests/Timer_Queue_Test.cpp | 77 |
4 files changed, 96 insertions, 2 deletions
diff --git a/ChangeLog b/ChangeLog index 22d0131ab58..b42c67728aa 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,20 @@ +Thu Mar 16 21:54:29 UTC 2006 Steve Huston <shuston@riverace.com> + + * ace/Timer_Heap_T.cpp (grow_heap): Reset timer_ids_min_free_ after + growing the heap. Fixes Bugzilla #2447 where timer IDs may be + improperly duplicated under certain conditions. + + * tests/Timer_Queue_Test.cpp: Added a new function, + test_unique_timer_heap_ids(), as supplied in Bugzilla #2447 to + verify the fix. + + Thank you very much to Dan Pozdol <dpozdol at wolve dot com> and + Paxton Mason <pmason at wolve dot com> for identifying the bug, + its conditions and causes, supplying the test program and supplying + the fix! + + * THANKS: Added Dan Pozdol to the Hall of Fame. + Thu Mar 16 16:30:00 UTC 2006 simon massey <sma@prismtech.com> * tests/run_test.lst @@ -2080,6 +2080,7 @@ Aaron Scamehorn <aaron dot scamehorn at cogcap dot com> Alan Kierstead <ackierstead at fedex dot com> Sven-Uwe Sieler-Hornke <sven-uwe dot sieler-hornke at investment-cybernetics dot de> Spencer Vanroekel <Spencer dot Vanroekel at Siemens dot com> +Dan Pozdol <dpozdol at wolve dot com> I would particularly like to thank Paul Stephenson, who worked with me at Ericsson in the early 1990's. Paul devised the recursive Makefile diff --git a/ace/Timer_Heap_T.cpp b/ace/Timer_Heap_T.cpp index dda9381e80d..644a13b90db 100644 --- a/ace/Timer_Heap_T.cpp +++ b/ace/Timer_Heap_T.cpp @@ -615,6 +615,9 @@ ACE_Timer_Heap_T<TYPE, FUNCTOR, ACE_LOCK>::grow_heap (void) } this->max_size_ = new_size; + // Force rescan of list from beginning for a free slot (I think...) + // This fixed Bugzilla #2447. + this->timer_ids_min_free_ = this->max_size_; } // Reschedule a periodic timer. This function must be called with the diff --git a/tests/Timer_Queue_Test.cpp b/tests/Timer_Queue_Test.cpp index 9a1845bb8b9..69f44084dbf 100644 --- a/tests/Timer_Queue_Test.cpp +++ b/tests/Timer_Queue_Test.cpp @@ -34,6 +34,9 @@ #include "ace/Recursive_Thread_Mutex.h" #include "ace/Null_Mutex.h" #include "ace/OS_NS_unistd.h" +#include "ace/Containers_T.h" + +#include <iostream> ACE_RCSID(tests, Timer_Queue_Test, "$Id$") @@ -475,6 +478,65 @@ test_performance (ACE_Timer_Queue *tq, delete [] times; } +// This test function was contributed with Bugzilla #2447 to test validity +// of ACE_Timer_Heap timer IDs around the boundary of having to enlarge +// the heap. +static void +test_unique_timer_heap_ids (void) +{ + Example_Handler eh; + ACE_Timer_Heap timer_heap (44); + ACE_Time_Value anytime(1); + ACE_Bounded_Set<long> timer_ids (max_iterations); + long timer_id = -1; + bool all_unique = true; + + for (int i = 0; i < 100; ++i) + { + timer_id = timer_heap.schedule (&eh, 0, anytime); + if (timer_id == -1) + { + ACE_ERROR ((LM_ERROR, + ACE_TEXT ("Schedule timer %d %p\n"), + i, + ACE_TEXT ("test_unique_timer_heap_ids"))); + continue; + } + ACE_DEBUG ((LM_DEBUG, + ACE_TEXT ("Schedule timer %d. Timer id = %d\n"), + i, + timer_id)); + if (1 == timer_ids.insert (timer_id)) + { + ACE_ERROR ((LM_ERROR, + ACE_TEXT ("Pass %d, id %d is not unique\n"), + i, + timer_id)); + all_unique = false; + } + + if (i == 0 || i == 1 || i == 47 || i == 48) + { + ACE_DEBUG ((LM_DEBUG, + ACE_TEXT ("Free Timer %d. Timer Id = %d\n"), + i, + timer_id)); + timer_heap.cancel (timer_id); + if (timer_id == -1) + ACE_ERROR ((LM_ERROR, + ACE_TEXT ("%p\n"), + ACE_TEXT ("Failed to cancel timer"))); + + timer_ids.remove (timer_id); + } + } + + if (all_unique) + ACE_DEBUG ((LM_INFO, ACE_TEXT ("All timer ids were unique.\n"))); + + return; +} + class Timer_Queue_Stack { // = TITLE @@ -558,7 +620,7 @@ run_main (int argc, ACE_TCHAR *argv[]) -1); // Timer_Heap without preallocated memory. ACE_NEW_RETURN (tq_stack, - Timer_Queue_Stack (new ACE_Timer_Heap, + Timer_Queue_Stack (new ACE_Timer_Heap (), ACE_TEXT ("ACE_Timer_Heap (non-preallocated)"), tq_stack), -1); @@ -600,9 +662,20 @@ run_main (int argc, ACE_TCHAR *argv[]) tq_ptr = tq_ptr->next_; delete temp; } - delete [] timer_ids; + ACE_DEBUG + ((LM_DEBUG, + ACE_TEXT ("**** starting unique IDs test for ACE_Timer_Heap\n"))); + test_unique_timer_heap_ids (); + ACE_END_TEST; return 0; } + + +#if defined (ACE_HAS_EXPLICIT_TEMPLATE_INSTANTIATION) +template class ACE_Bounded_Set<long>; +#elif defined (ACE_HAS_TEMPLATE_INSTANTIATION_PRAGMA) +#pragma instantiate ACE_Bounded_Set<long> +#endif /* ACE_HAS_EXPLICIT_TEMPLATE_INSTANTIATION */ |