diff options
author | Johnny Willemsen <jwillemsen@remedy.nl> | 2007-05-03 08:40:50 +0000 |
---|---|---|
committer | Johnny Willemsen <jwillemsen@remedy.nl> | 2007-05-03 08:40:50 +0000 |
commit | 3d02ea749b7ff835bfb26971882f90adb4921a25 (patch) | |
tree | 53fa9d905084c19feb7993ebab6dc6d4734fb755 | |
parent | 754e9bb95b25c89f9800a812073e7b7d3091760b (diff) | |
download | ATCD-3d02ea749b7ff835bfb26971882f90adb4921a25.tar.gz |
Thu May 3 08:37:37 UTC 2007 Johnny Willemsen <jwillemsen@remedy.nl>
-rw-r--r-- | ACE/ChangeLog | 21 | ||||
-rw-r--r-- | ACE/ace/Dev_Poll_Reactor.cpp | 10 | ||||
-rw-r--r-- | ACE/ace/Event_Handler.cpp | 4 | ||||
-rw-r--r-- | ACE/ace/Svc_Handler.cpp | 6 | ||||
-rw-r--r-- | ACE/ace/Timer_Queue_T.cpp | 2 | ||||
-rw-r--r-- | ACE/ace/WFMO_Reactor.cpp | 2 | ||||
-rw-r--r-- | ACE/ace/config-hpux-11.00.h | 5 | ||||
-rw-r--r-- | ACE/tests/Bug_2609_Regression_Test.cpp | 146 | ||||
-rw-r--r-- | ACE/tests/run_test.lst | 1 | ||||
-rw-r--r-- | ACE/tests/tests.mpc | 7 |
10 files changed, 193 insertions, 11 deletions
diff --git a/ACE/ChangeLog b/ACE/ChangeLog index b85bf02d517..583f6db22ff 100644 --- a/ACE/ChangeLog +++ b/ACE/ChangeLog @@ -1,3 +1,24 @@ +Thu May 3 08:37:37 UTC 2007 Johnny Willemsen <jwillemsen@remedy.nl> + + * tests/run_test.lst: + * tests/Bug_2609_Regression_Test.cpp: + * ace/Svc_Handler.cpp: + * tests/tests.mpc: + Fixed bug 2609, take into account reference counted svc handlers. + Thanks to Milan Cvetkovic <milan dot cvetkovic at mpathix dot com> + for reporting this, providing the patch and the regression test + + * ace/config-hpux-11.00.h: + dllexport with template specializations doesn't work for HP aCC + 3.x which runs on PARISC. Reported this to HP and for the moment + disable dllexport usage on PARISC totally + + * ace/Dev_Poll_Reactor.cpp: + * ace/Event_Handler.cpp: + * ace/Timer_Queue_T.cpp: + * ace/WFMO_Reactor.cpp: + Use bool when possible + Wed May 2 18:43:37 UTC 2007 Johnny Willemsen <jwillemsen@remedy.nl> * docs/bczar/bczar.html: diff --git a/ACE/ace/Dev_Poll_Reactor.cpp b/ACE/ace/Dev_Poll_Reactor.cpp index 6a25648d6fd..ba1fb8c3dd4 100644 --- a/ACE/ace/Dev_Poll_Reactor.cpp +++ b/ACE/ace/Dev_Poll_Reactor.cpp @@ -132,7 +132,7 @@ ACE_Dev_Poll_Reactor_Notify::notify (ACE_Event_Handler *eh, #if defined (ACE_HAS_REACTOR_NOTIFICATION_QUEUE) ACE_Dev_Poll_Handler_Guard eh_guard (eh); - int notification_required = + int notification_required = notification_queue_.push_new_notification (buffer); if (notification_required == -1) @@ -230,8 +230,8 @@ ACE_Dev_Poll_Reactor_Notify::read_notify_pipe (ACE_HANDLE handle, bool more_messages_queued = false; ACE_Notification_Buffer next; - int result = notification_queue_.pop_next_notification (buffer, - more_messages_queued, + int result = notification_queue_.pop_next_notification (buffer, + more_messages_queued, next); if (result == 0) @@ -240,7 +240,7 @@ ACE_Dev_Poll_Reactor_Notify::read_notify_pipe (ACE_HANDLE handle, ACE::recv (handle, read_p, to_read); return 0; } - + if (result == -1) return -1; @@ -1573,7 +1573,7 @@ ACE_Dev_Poll_Reactor::remove_handler_i (ACE_HANDLE handle, return -1; // Check for ref counting now - handle_close () may delete eh. - int requires_reference_counting = + bool const requires_reference_counting = eh->reference_counting_policy ().value () == ACE_Event_Handler::Reference_Counting_Policy::ENABLED; diff --git a/ACE/ace/Event_Handler.cpp b/ACE/ace/Event_Handler.cpp index 266f4984aa6..d4542b61349 100644 --- a/ACE/ace/Event_Handler.cpp +++ b/ACE/ace/Event_Handler.cpp @@ -184,7 +184,7 @@ ACE_Event_Handler::reactor_timer_interface (void) const ACE_Event_Handler::Reference_Count ACE_Event_Handler::add_reference (void) { - int reference_counting_required = + bool const reference_counting_required = this->reference_counting_policy ().value () == ACE_Event_Handler::Reference_Counting_Policy::ENABLED; @@ -197,7 +197,7 @@ ACE_Event_Handler::add_reference (void) ACE_Event_Handler::Reference_Count ACE_Event_Handler::remove_reference (void) { - int reference_counting_required = + bool const reference_counting_required = this->reference_counting_policy ().value () == ACE_Event_Handler::Reference_Counting_Policy::ENABLED; diff --git a/ACE/ace/Svc_Handler.cpp b/ACE/ace/Svc_Handler.cpp index 9873fc95ff0..93418d401b5 100644 --- a/ACE/ace/Svc_Handler.cpp +++ b/ACE/ace/Svc_Handler.cpp @@ -304,7 +304,11 @@ ACE_Svc_Handler<PR_ST_2, ACE_SYNCH_USE>::handle_close (ACE_HANDLE, { ACE_TRACE ("ACE_Svc_Handler<PR_ST_2, ACE_SYNCH_USE>::handle_close"); - this->destroy (); + if (reference_counting_policy().value() != + Reference_Counting_Policy::ENABLED) + { + this->destroy (); + } return 0; } diff --git a/ACE/ace/Timer_Queue_T.cpp b/ACE/ace/Timer_Queue_T.cpp index 246700f6aa2..6879eea9ac8 100644 --- a/ACE/ace/Timer_Queue_T.cpp +++ b/ACE/ace/Timer_Queue_T.cpp @@ -363,7 +363,7 @@ ACE_Event_Handler_Handle_Timeout_Upcall<ACE_LOCK>::preinvoke (TIMER_QUEUE & /* t const ACE_Time_Value & /* cur_time */, const void *&upcall_act) { - int requires_reference_counting = + bool const requires_reference_counting = event_handler->reference_counting_policy ().value () == ACE_Event_Handler::Reference_Counting_Policy::ENABLED; diff --git a/ACE/ace/WFMO_Reactor.cpp b/ACE/ace/WFMO_Reactor.cpp index 506f211095e..55e28594acf 100644 --- a/ACE/ace/WFMO_Reactor.cpp +++ b/ACE/ace/WFMO_Reactor.cpp @@ -772,7 +772,7 @@ ACE_WFMO_Reactor_Handler_Repository::make_changes_in_current_infos (void) // the upcall. if (event_handler != 0) { - int requires_reference_counting = + bool const requires_reference_counting = event_handler->reference_counting_policy ().value () == ACE_Event_Handler::Reference_Counting_Policy::ENABLED; diff --git a/ACE/ace/config-hpux-11.00.h b/ACE/ace/config-hpux-11.00.h index 30291535577..ef4e84d74ac 100644 --- a/ACE/ace/config-hpux-11.00.h +++ b/ACE/ace/config-hpux-11.00.h @@ -133,7 +133,10 @@ // Compiler doesn't handle 'signed char' correctly (used in ace/IOStream.h) # define ACE_LACKS_SIGNED_CHAR -# if (__HP_aCC >= 35502) +// dllexport/dllimport should work for 3.55 and newer but testing show that +// dllexport for template specializations only works for the 6.x versions +// which run on IA64 +# if (__HP_aCC >= 35502) && defined (__ia64) # define ACE_HAS_CUSTOM_EXPORT_MACROS # define ACE_Proper_Export_Flag __declspec (dllexport) # define ACE_Proper_Import_Flag __declspec (dllimport) diff --git a/ACE/tests/Bug_2609_Regression_Test.cpp b/ACE/tests/Bug_2609_Regression_Test.cpp new file mode 100644 index 00000000000..2ca3b0af13a --- /dev/null +++ b/ACE/tests/Bug_2609_Regression_Test.cpp @@ -0,0 +1,146 @@ +/** + * @file Bug_2609_Regression_Test.cpp + * + * $Id$ + * + * Reproduces the problems reported in bug 2609: + * http://deuce.doc.wustl.edu/bugzilla/show_bug.cgi?id=2609 + * + * @author Milan Cvetkovic <milan.cvetkovic@mpathix.com> + */ + +#include "test_config.h" + +ACE_RCSID (tests, + Bug_2609_Regression_Test, + "$Id$") + +#include "ace/Svc_Handler.h" +#include "ace/Acceptor.h" +#include "ace/SOCK_Stream.h" +#include "ace/SOCK_Acceptor.h" +#include "ace/INET_Addr.h" +#include "ace/Trace.h" +#include "ace/SOCK_Connector.h" +#include "ace/Thread_Semaphore.h" + +#if defined (ACE_HAS_THREADS) + +# define TRACE(X) ACE_Trace ____ (ACE_LIB_TEXT (X), __LINE__, ACE_LIB_TEXT (__FILE__)) + +bool g_handler_deleted = false; +// use semaphore for synchronization +// +ACE_Thread_Semaphore g_semaphore (0); + +class My_Svc_Handler : public ACE_Svc_Handler<ACE_SOCK_STREAM,ACE_NULL_SYNCH> +{ +public: + typedef ACE_Svc_Handler<ACE_SOCK_STREAM,ACE_NULL_SYNCH> super; + My_Svc_Handler() + { + TRACE ("My_Svc_Handler:My_Svc_Handler"); + g_handler_deleted = false; + reference_counting_policy().value( + Reference_Counting_Policy::ENABLED); + } + + ~My_Svc_Handler() + { + TRACE ("My_Svc_Handler::~My_Svc_Handler"); + g_handler_deleted = true; + } + + int open (void* pv) + { + TRACE ("open"); + g_semaphore.release(); // signal open completed + return super::open (pv); + } + + int handle_close (ACE_HANDLE fd, ACE_Reactor_Mask mask) + { + TRACE ("handle_close"); + super::handle_close (fd, mask); + if (g_handler_deleted) + { + ACE_ERROR ((LM_ERROR, + ACE_TEXT("Handler deleted in base class' handle_close()\n"))); + } + // signal handle_close() completed + g_semaphore.release(); + return 0; + } +}; + +struct My_Task : public ACE_Task_Base +{ + int svc() + { + TRACE ("My_Task::svc"); + ACE_Reactor::instance()->owner(ACE_OS::thr_self()); + int rv = ACE_Reactor::instance()->run_reactor_event_loop(); + if (rv < 0) + { + ACE_ERROR ((LM_ERROR, ACE_TEXT("Cannot run reactor event loop\n"))); + } + return 0; + } +}; + +// event handler used to signal when the reactor started +struct Timer_Handler : public ACE_Event_Handler +{ + int handle_timeout (const ACE_Time_Value&, const void*) + { + g_semaphore.release(); // signal reactor started + return 0; + } +}; + +typedef ACE_Acceptor<My_Svc_Handler, ACE_SOCK_ACCEPTOR> My_Acceptor; + +#endif + +int +run_main (int, ACE_TCHAR *[]) +{ + ACE_START_TEST (ACE_TEXT ("Bug_2609_Regression_Test")); + +#if defined (ACE_HAS_THREADS) + + My_Acceptor acceptor (ACE_INET_Addr(9876)); + Timer_Handler timer_handler; + ACE_Reactor::instance()->schedule_timer( + &timer_handler, 0, ACE_Time_Value(0)); + + My_Task task; + int activated = task.activate(); + if (activated < 0) + { + ACE_ERROR ((LM_ERROR, ACE_TEXT ("Could not activate task\n"))); + } + + g_semaphore.acquire();// wait for reactor to start + { + ACE_SOCK_Connector c1; + ACE_SOCK_Stream s1; + ACE_INET_Addr a1(9876, "localhost"); + if (-1 == c1.connect (s1, a1)) + { + ACE_ERROR_RETURN ((LM_ERROR, ACE_TEXT("Could not connect\n")), -1); + } + g_semaphore.acquire(); // wait for open to complete + s1.close(); + g_semaphore.acquire(); // wait for handle_close to complete + } + ACE_Reactor::end_event_loop(); + task.wait(); +#else + ACE_ERROR ((LM_INFO, + ACE_TEXT ("threads not supported on this platform\n"))); +#endif + ACE_END_TEST; + + return 0; +} diff --git a/ACE/tests/run_test.lst b/ACE/tests/run_test.lst index 24f99b17be8..53c14b909e0 100644 --- a/ACE/tests/run_test.lst +++ b/ACE/tests/run_test.lst @@ -34,6 +34,7 @@ Bug_1890_Regression_Test Bug_2368_Regression_Test Bug_2497_Regression_Test Bug_2540_Regression_Test +Bug_2609_Regression_Test: !ST Bug_2659_Regression_Test: !ST Bug_2653_Regression_Test: !ST Bug_2815_Regression_Test diff --git a/ACE/tests/tests.mpc b/ACE/tests/tests.mpc index f30ba7ded25..6a6efbef6fb 100644 --- a/ACE/tests/tests.mpc +++ b/ACE/tests/tests.mpc @@ -1428,6 +1428,13 @@ project(Bug_2659_Regression_Test) : acetest { } } +project(Bug_2609_Regression_Test) : acetest { + exename = Bug_2609_Regression_Test + Source_Files { + Bug_2609_Regression_Test.cpp + } +} + project(Bug_2912_Regression_Test) : acetest, ssl { avoids += ace_for_tao exename = Bug_2912_Regression_Test |