diff options
author | schmidt <douglascraigschmidt@users.noreply.github.com> | 1998-04-10 06:11:12 +0000 |
---|---|---|
committer | schmidt <douglascraigschmidt@users.noreply.github.com> | 1998-04-10 06:11:12 +0000 |
commit | 1c9aa0771f0da0b0562d0b22857b6716d665cee0 (patch) | |
tree | dbb72edfcd634835be0aff8ccb89cbfe425e01fc /tests/Reactor_Exceptions_Test.cpp | |
parent | a77dab645a463a64974db9741ecee83a08c5e91e (diff) | |
download | ATCD-1c9aa0771f0da0b0562d0b22857b6716d665cee0.tar.gz |
*** empty log message ***
Diffstat (limited to 'tests/Reactor_Exceptions_Test.cpp')
-rw-r--r-- | tests/Reactor_Exceptions_Test.cpp | 65 |
1 files changed, 42 insertions, 23 deletions
diff --git a/tests/Reactor_Exceptions_Test.cpp b/tests/Reactor_Exceptions_Test.cpp index 8b946aa0402..63e79e4bcc5 100644 --- a/tests/Reactor_Exceptions_Test.cpp +++ b/tests/Reactor_Exceptions_Test.cpp @@ -27,8 +27,11 @@ #if defined (ACE_WIN32) static void -raise_exception (void) +throw_exception (void) { + ACE_DEBUG ((LM_DEBUG, + "(%P|%t) throw exception\n")); + // Cause a Win32 structured exception. *(char *) 0 = 0; } @@ -37,34 +40,36 @@ raise_exception (void) class Except {}; static void -raise_exception (void) +throw_exception (void) { + ACE_DEBUG ((LM_DEBUG, + "(%P|%t) throw exception\n")); throw Except (); } #endif /* ACE_WIN32 */ -class Memory_Exception : public ACE_Event_Handler, public ACE_SOCK_Dgram +class My_Handler : public ACE_Event_Handler, public ACE_SOCK_Dgram { public: - Memory_Exception (const ACE_INET_Addr &local_addr); + My_Handler (const ACE_INET_Addr &local_addr); virtual ACE_HANDLE get_handle (void) const; virtual int handle_input (ACE_HANDLE handle); }; -Memory_Exception::Memory_Exception (const ACE_INET_Addr &local_addr) +My_Handler::My_Handler (const ACE_INET_Addr &local_addr) : ACE_SOCK_Dgram (local_addr) { } ACE_HANDLE -Memory_Exception::get_handle (void) const +My_Handler::get_handle (void) const { return ACE_SOCK_Dgram::get_handle (); } int -Memory_Exception::handle_input (ACE_HANDLE) +My_Handler::handle_input (ACE_HANDLE) { char buf[BUFSIZ]; ACE_INET_Addr from_addr; @@ -73,8 +78,9 @@ Memory_Exception::handle_input (ACE_HANDLE) "Activity occurred on handle %d!\n", ACE_SOCK_Dgram::get_handle ())); - ssize_t n = ACE_SOCK_Dgram::recv (buf, sizeof buf, from_addr); - + ssize_t n = ACE_SOCK_Dgram::recv (buf, + sizeof buf, + from_addr); if (n == -1) ACE_ERROR ((LM_ERROR, "%p\n", @@ -84,7 +90,7 @@ Memory_Exception::handle_input (ACE_HANDLE) "got buf = %s\n", buf)); - raise_exception (); + throw_exception (); ACE_NOTREACHED (return 0); } @@ -100,7 +106,8 @@ public: } catch (...) { - ACE_DEBUG ((LM_DEBUG, " (%t) caught exception\n")); + ACE_DEBUG ((LM_DEBUG, + " (%t) catch exception\n")); ret = -1; // do your thing, etc. } @@ -120,7 +127,9 @@ worker (void) for (;;) if (ACE_Reactor::instance ()->handle_events () == -1) - ACE_ERROR_RETURN ((LM_ERROR, " (%t) error return\n"), -1); + ACE_ERROR_RETURN ((LM_ERROR, + " (%t) exception return\n"), + 0); ACE_NOTREACHED (return 0); } @@ -136,42 +145,52 @@ main (int argc, char *argv[]) u_short port = argc > 1 ? ACE_OS::atoi (argv[1]) : ACE_DEFAULT_SERVER_PORT; - ACE_DEBUG ((LM_DEBUG, "Starting tracing\n")); - ACE_LOG_MSG->start_tracing (); + ACE_DEBUG ((LM_DEBUG, + "Starting tracing\n")); ACE_Reactor::instance (&reactor); - ACE_Thread_Manager *thr_mgr = ACE_Thread_Manager::instance (); + ACE_Thread_Manager *thr_mgr = + ACE_Thread_Manager::instance (); ACE_INET_Addr local_addr (port); ACE_INET_Addr remote_addr (port, ACE_DEFAULT_SERVER_HOST); - Memory_Exception ex (local_addr); + My_Handler handler (local_addr); if (ACE_Reactor::instance ()->register_handler - (&ex, ACE_Event_Handler::READ_MASK) == -1) - ACE_ERROR_RETURN ((LM_ERROR, "%p\n%a", "register_handler", 1), -1); + (&handler, + ACE_Event_Handler::READ_MASK) == -1) + ACE_ERROR_RETURN ((LM_ERROR, + "%p\n", + "register_handler"), + -1); #if defined (ACE_HAS_THREADS) thr_mgr->spawn (ACE_THR_FUNC (worker)); #else // Need to figure out how to implement this test. - ACE_ERROR ((LM_ERROR, "threads not supported on this platform\n")); + ACE_ERROR ((LM_ERROR, + "threads not supported on this platform\n")); #endif /* ACE_HAS_THREADS */ ACE_SOCK_Dgram dgram ((ACE_INET_Addr &) ACE_Addr::sap_any); for (size_t i = 0; i < ACE_MAX_ITERATIONS; i++) - dgram.send ("Hello", 6, remote_addr); + dgram.send ("Hello", sizeof ("Hello"), remote_addr); + // Barrier to wait for the other thread to return. thr_mgr->wait (); - ex.close (); + + handler.close (); dgram.close (); - ACE_DEBUG ((LM_DEBUG, " (%t) exiting main\n")); + ACE_DEBUG ((LM_DEBUG, + " (%t) exiting main\n")); #else ACE_UNUSED_ARG (argc); ACE_UNUSED_ARG (argv); - ACE_ERROR ((LM_ERROR, "C++ exceptions not supported on this platform\n")); + ACE_ERROR ((LM_ERROR, + "C++ exceptions not supported on this platform\n")); #endif /* ACE_HAS_EXCEPTIONS */ ACE_END_TEST; |