diff options
author | irfan <irfan@ae88bc3d-4319-0410-8dbf-d08b4c9d3795> | 1998-11-21 02:32:45 +0000 |
---|---|---|
committer | irfan <irfan@ae88bc3d-4319-0410-8dbf-d08b4c9d3795> | 1998-11-21 02:32:45 +0000 |
commit | b2324643449b1f4e3f27d6f6b0093fde42456d81 (patch) | |
tree | 3a4a0e76d85d6c527b52ec85255c2800c9fdcf50 | |
parent | bbee534c52bef8a13b9f893f8ea17ed237d26d82 (diff) | |
download | ATCD-b2324643449b1f4e3f27d6f6b0093fde42456d81.tar.gz |
*** empty log message ***
18 files changed, 327 insertions, 21 deletions
diff --git a/ChangeLog-98b b/ChangeLog-98b index dd327c2c19a..1e055fef19f 100644 --- a/ChangeLog-98b +++ b/ChangeLog-98b @@ -6,11 +6,13 @@ Fri Nov 20 15:49:04 1998 Irfan Pyarali <irfan@cs.wustl.edu> handle_close() called for all three masks (READ, WRITE, and EXCEPT). - * ace/WFMO_Reactor.cpp (remove_handler_i): There was a bug in - WFMO_Reactor where handle_close() was not called when it is not - a complete removal. Added a call to handle_close() for all the - masks that were removed. Note that partial removals do not - change the state of the internal tables of the reactor. + * ace/WFMO_Reactor.cpp (remove_handler_i, + remove_suspended_handler_i, and remove_to_be_added_handler_i): + There was a bug in WFMO_Reactor where handle_close() was not + called when it is not a complete removal. Added a call to + handle_close() for all the masks that were removed. Note that + partial removals do not change the state of the internal tables + of the reactor. * ace/OS.i (recvfrom): There is a bug in the Win32 implementation of this function. It reports an error (with errno=WSAEMSGSIZE), diff --git a/examples/Reactor/WFMO_Reactor/APC.DSP b/examples/Reactor/WFMO_Reactor/APC.DSP index 255486faab9..a225676e17c 100644 --- a/examples/Reactor/WFMO_Reactor/APC.DSP +++ b/examples/Reactor/WFMO_Reactor/APC.DSP @@ -8,12 +8,12 @@ CFG=APC - Win32 Debug !MESSAGE This is not a valid makefile. To build this project using NMAKE, !MESSAGE use the Export Makefile command and run !MESSAGE -!MESSAGE NMAKE /f "APC.MAK". +!MESSAGE NMAKE /f "Apc.mak". !MESSAGE !MESSAGE You can specify a configuration when running NMAKE !MESSAGE by defining the macro CFG on the command line. For example: !MESSAGE -!MESSAGE NMAKE /f "APC.MAK" CFG="APC - Win32 Debug" +!MESSAGE NMAKE /f "Apc.mak" CFG="APC - Win32 Debug" !MESSAGE !MESSAGE Possible choices for configuration are: !MESSAGE diff --git a/examples/Reactor/WFMO_Reactor/Abondoned.dsp b/examples/Reactor/WFMO_Reactor/Abondoned.dsp index d113db90ba6..7e91e07a8c1 100644 --- a/examples/Reactor/WFMO_Reactor/Abondoned.dsp +++ b/examples/Reactor/WFMO_Reactor/Abondoned.dsp @@ -1,5 +1,5 @@ # Microsoft Developer Studio Project File - Name="Abondoned" - Package Owner=<4>
-# Microsoft Developer Studio Generated Build File, Format Version 6.00
+# Microsoft Developer Studio Generated Build File, Format Version 5.00
# ** DO NOT EDIT **
# TARGTYPE "Win32 (x86) Console Application" 0x0103
diff --git a/examples/Reactor/WFMO_Reactor/Console_Input.dsp b/examples/Reactor/WFMO_Reactor/Console_Input.dsp index b5f5b870dde..dee20eef64b 100644 --- a/examples/Reactor/WFMO_Reactor/Console_Input.dsp +++ b/examples/Reactor/WFMO_Reactor/Console_Input.dsp @@ -1,5 +1,5 @@ # Microsoft Developer Studio Project File - Name="Console_Input" - Package Owner=<4>
-# Microsoft Developer Studio Generated Build File, Format Version 6.00
+# Microsoft Developer Studio Generated Build File, Format Version 5.00
# ** DO NOT EDIT **
# TARGTYPE "Win32 (x86) Console Application" 0x0103
diff --git a/examples/Reactor/WFMO_Reactor/Directory_Changes.dsp b/examples/Reactor/WFMO_Reactor/Directory_Changes.dsp index cea930eac62..db31714291a 100644 --- a/examples/Reactor/WFMO_Reactor/Directory_Changes.dsp +++ b/examples/Reactor/WFMO_Reactor/Directory_Changes.dsp @@ -1,5 +1,5 @@ # Microsoft Developer Studio Project File - Name="Directory_Changes" - Package Owner=<4>
-# Microsoft Developer Studio Generated Build File, Format Version 6.00
+# Microsoft Developer Studio Generated Build File, Format Version 5.00
# ** DO NOT EDIT **
# TARGTYPE "Win32 (x86) Console Application" 0x0103
diff --git a/examples/Reactor/WFMO_Reactor/Exceptions.dsp b/examples/Reactor/WFMO_Reactor/Exceptions.dsp index 51a8324d72f..5a854c2e609 100644 --- a/examples/Reactor/WFMO_Reactor/Exceptions.dsp +++ b/examples/Reactor/WFMO_Reactor/Exceptions.dsp @@ -1,5 +1,5 @@ # Microsoft Developer Studio Project File - Name="Exceptions" - Package Owner=<4>
-# Microsoft Developer Studio Generated Build File, Format Version 6.00
+# Microsoft Developer Studio Generated Build File, Format Version 5.00
# ** DO NOT EDIT **
# TARGTYPE "Win32 (x86) Console Application" 0x0103
diff --git a/examples/Reactor/WFMO_Reactor/Handle_Close.dsp b/examples/Reactor/WFMO_Reactor/Handle_Close.dsp new file mode 100644 index 00000000000..852fe3c339b --- /dev/null +++ b/examples/Reactor/WFMO_Reactor/Handle_Close.dsp @@ -0,0 +1,58 @@ +# Microsoft Developer Studio Project File - Name="Handle_Close" - Package Owner=<4>
+# Microsoft Developer Studio Generated Build File, Format Version 5.00
+# ** DO NOT EDIT **
+
+# TARGTYPE "Win32 (x86) Console Application" 0x0103
+
+CFG=Handle_Close - Win32 Debug
+!MESSAGE This is not a valid makefile. To build this project using NMAKE,
+!MESSAGE use the Export Makefile command and run
+!MESSAGE
+!MESSAGE NMAKE /f "Handle_Close.mak".
+!MESSAGE
+!MESSAGE You can specify a configuration when running NMAKE
+!MESSAGE by defining the macro CFG on the command line. For example:
+!MESSAGE
+!MESSAGE NMAKE /f "Handle_Close.mak" CFG="Handle_Close - Win32 Debug"
+!MESSAGE
+!MESSAGE Possible choices for configuration are:
+!MESSAGE
+!MESSAGE "Handle_Close - Win32 Debug" (based on\
+ "Win32 (x86) Console Application")
+!MESSAGE
+
+# Begin Project
+# PROP Scc_ProjName ""
+# PROP Scc_LocalPath ""
+CPP=cl.exe
+RSC=rc.exe
+# PROP BASE Use_MFC 0
+# PROP BASE Use_Debug_Libraries 1
+# PROP BASE Output_Dir "Handle_C"
+# PROP BASE Intermediate_Dir "Handle_C"
+# PROP BASE Target_Dir ""
+# PROP Use_MFC 0
+# PROP Use_Debug_Libraries 1
+# PROP Output_Dir ""
+# PROP Intermediate_Dir "Debug"
+# PROP Ignore_Export_Lib 0
+# PROP Target_Dir ""
+# ADD BASE CPP /nologo /W3 /Gm /GX /Zi /Od /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c
+# ADD CPP /nologo /MDd /W3 /Gm /GX /Zi /Od /I "..\..\..\\" /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c
+# ADD BASE RSC /l 0x409 /d "_DEBUG"
+# ADD RSC /l 0x409 /d "_DEBUG"
+BSC32=bscmake.exe
+# ADD BASE BSC32 /nologo
+# ADD BSC32 /nologo
+LINK32=link.exe
+# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept
+# ADD LINK32 aced.lib /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept /libpath:"..\..\..\ace"
+# Begin Target
+
+# Name "Handle_Close - Win32 Debug"
+# Begin Source File
+
+SOURCE=.\test_handle_close.cpp
+# End Source File
+# End Target
+# End Project
diff --git a/examples/Reactor/WFMO_Reactor/Multithreading.dsp b/examples/Reactor/WFMO_Reactor/Multithreading.dsp index 378d7483ca7..d6960735080 100644 --- a/examples/Reactor/WFMO_Reactor/Multithreading.dsp +++ b/examples/Reactor/WFMO_Reactor/Multithreading.dsp @@ -1,5 +1,5 @@ # Microsoft Developer Studio Project File - Name="Multithreading" - Package Owner=<4>
-# Microsoft Developer Studio Generated Build File, Format Version 6.00
+# Microsoft Developer Studio Generated Build File, Format Version 5.00
# ** DO NOT EDIT **
# TARGTYPE "Win32 (x86) Console Application" 0x0103
diff --git a/examples/Reactor/WFMO_Reactor/Network_Events.dsp b/examples/Reactor/WFMO_Reactor/Network_Events.dsp index be0d021963e..f9e9f82bce4 100644 --- a/examples/Reactor/WFMO_Reactor/Network_Events.dsp +++ b/examples/Reactor/WFMO_Reactor/Network_Events.dsp @@ -1,5 +1,5 @@ # Microsoft Developer Studio Project File - Name="Network_Events" - Package Owner=<4>
-# Microsoft Developer Studio Generated Build File, Format Version 6.00
+# Microsoft Developer Studio Generated Build File, Format Version 5.00
# ** DO NOT EDIT **
# TARGTYPE "Win32 (x86) Console Application" 0x0103
diff --git a/examples/Reactor/WFMO_Reactor/Prerun_State_Changes.dsp b/examples/Reactor/WFMO_Reactor/Prerun_State_Changes.dsp index c8d344a9966..802e4a10b71 100644 --- a/examples/Reactor/WFMO_Reactor/Prerun_State_Changes.dsp +++ b/examples/Reactor/WFMO_Reactor/Prerun_State_Changes.dsp @@ -1,5 +1,5 @@ # Microsoft Developer Studio Project File - Name="Prerun_State_Changes" - Package Owner=<4>
-# Microsoft Developer Studio Generated Build File, Format Version 6.00
+# Microsoft Developer Studio Generated Build File, Format Version 5.00
# ** DO NOT EDIT **
# TARGTYPE "Win32 (x86) Console Application" 0x0103
diff --git a/examples/Reactor/WFMO_Reactor/Registration.dsp b/examples/Reactor/WFMO_Reactor/Registration.dsp index c716a2a552c..6ec245c5e29 100644 --- a/examples/Reactor/WFMO_Reactor/Registration.dsp +++ b/examples/Reactor/WFMO_Reactor/Registration.dsp @@ -1,5 +1,5 @@ # Microsoft Developer Studio Project File - Name="Registration" - Package Owner=<4>
-# Microsoft Developer Studio Generated Build File, Format Version 6.00
+# Microsoft Developer Studio Generated Build File, Format Version 5.00
# ** DO NOT EDIT **
# TARGTYPE "Win32 (x86) Console Application" 0x0103
diff --git a/examples/Reactor/WFMO_Reactor/Registry_Changes.dsp b/examples/Reactor/WFMO_Reactor/Registry_Changes.dsp index 6effdcc5759..818d20bc4b5 100644 --- a/examples/Reactor/WFMO_Reactor/Registry_Changes.dsp +++ b/examples/Reactor/WFMO_Reactor/Registry_Changes.dsp @@ -1,5 +1,5 @@ # Microsoft Developer Studio Project File - Name="Registry_Changes" - Package Owner=<4>
-# Microsoft Developer Studio Generated Build File, Format Version 6.00
+# Microsoft Developer Studio Generated Build File, Format Version 5.00
# ** DO NOT EDIT **
# TARGTYPE "Win32 (x86) Console Application" 0x0103
diff --git a/examples/Reactor/WFMO_Reactor/Removals.dsp b/examples/Reactor/WFMO_Reactor/Removals.dsp index f888c8dc336..ec134a8b5b2 100644 --- a/examples/Reactor/WFMO_Reactor/Removals.dsp +++ b/examples/Reactor/WFMO_Reactor/Removals.dsp @@ -1,5 +1,5 @@ # Microsoft Developer Studio Project File - Name="Removals" - Package Owner=<4>
-# Microsoft Developer Studio Generated Build File, Format Version 6.00
+# Microsoft Developer Studio Generated Build File, Format Version 5.00
# ** DO NOT EDIT **
# TARGTYPE "Win32 (x86) Console Application" 0x0103
diff --git a/examples/Reactor/WFMO_Reactor/Talker.dsp b/examples/Reactor/WFMO_Reactor/Talker.dsp index 500af90cee6..2762406823b 100644 --- a/examples/Reactor/WFMO_Reactor/Talker.dsp +++ b/examples/Reactor/WFMO_Reactor/Talker.dsp @@ -1,5 +1,5 @@ # Microsoft Developer Studio Project File - Name="Talker" - Package Owner=<4>
-# Microsoft Developer Studio Generated Build File, Format Version 6.00
+# Microsoft Developer Studio Generated Build File, Format Version 5.00
# ** DO NOT EDIT **
# TARGTYPE "Win32 (x86) Console Application" 0x0103
diff --git a/examples/Reactor/WFMO_Reactor/Timeouts.dsp b/examples/Reactor/WFMO_Reactor/Timeouts.dsp index 764458116ab..1cbe5204645 100644 --- a/examples/Reactor/WFMO_Reactor/Timeouts.dsp +++ b/examples/Reactor/WFMO_Reactor/Timeouts.dsp @@ -1,5 +1,5 @@ # Microsoft Developer Studio Project File - Name="Timeouts" - Package Owner=<4>
-# Microsoft Developer Studio Generated Build File, Format Version 6.00
+# Microsoft Developer Studio Generated Build File, Format Version 5.00
# ** DO NOT EDIT **
# TARGTYPE "Win32 (x86) Console Application" 0x0103
diff --git a/examples/Reactor/WFMO_Reactor/WFMO_Reactor.dsw b/examples/Reactor/WFMO_Reactor/WFMO_Reactor.dsw index 24799c62d1a..81f8e0d8760 100644 --- a/examples/Reactor/WFMO_Reactor/WFMO_Reactor.dsw +++ b/examples/Reactor/WFMO_Reactor/WFMO_Reactor.dsw @@ -1,4 +1,4 @@ -Microsoft Developer Studio Workspace File, Format Version 6.00
+Microsoft Developer Studio Workspace File, Format Version 5.00
# WARNING: DO NOT EDIT OR DELETE THIS WORKSPACE FILE!
###############################################################################
@@ -63,6 +63,18 @@ Package=<4> ###############################################################################
+Project: "Handle_Close"=.\Handle_Close.dsp - Package Owner=<4>
+
+Package=<5>
+{{{
+}}}
+
+Package=<4>
+{{{
+}}}
+
+###############################################################################
+
Project: "Multithreading"=.\Multithreading.dsp - Package Owner=<4>
Package=<5>
diff --git a/examples/Reactor/WFMO_Reactor/Window_Messages.dsp b/examples/Reactor/WFMO_Reactor/Window_Messages.dsp index 5be34bd2132..6cc17adad04 100644 --- a/examples/Reactor/WFMO_Reactor/Window_Messages.dsp +++ b/examples/Reactor/WFMO_Reactor/Window_Messages.dsp @@ -1,5 +1,5 @@ # Microsoft Developer Studio Project File - Name="Window_Messages" - Package Owner=<4>
-# Microsoft Developer Studio Generated Build File, Format Version 6.00
+# Microsoft Developer Studio Generated Build File, Format Version 5.00
# ** DO NOT EDIT **
# TARGTYPE "Win32 (x86) Console Application" 0x0103
diff --git a/examples/Reactor/WFMO_Reactor/test_handle_close.cpp b/examples/Reactor/WFMO_Reactor/test_handle_close.cpp new file mode 100644 index 00000000000..7159c9ae96b --- /dev/null +++ b/examples/Reactor/WFMO_Reactor/test_handle_close.cpp @@ -0,0 +1,234 @@ +// $Id$ +// +// ============================================================================ +// +// = LIBRARY +// examples +// +// = FILENAME +// test_handle_close.cpp +// +// = DESCRIPTION +// +// This application tests whether handle_close gets called and if +// the correct masks are passed along. The handler should get +// handle_close called for all three masks (READ, WRITE, and +// EXCEPT). +// +// = AUTHOR +// Irfan Pyarali +// +// ============================================================================ + +#include "ace/Get_Opt.h" +#include "ace/Reactor.h" +#include "ace/WFMO_Reactor.h" +#include "ace/Select_Reactor.h" +#include "ace/Auto_Ptr.h" +#include "ace/Pipe.h" + +ACE_RCSID(WFMO_Reactor, test_handle_close, "$Id$") + +// Use the WFMO_Reactor +static int opt_wfmo_reactor = 0; + +// Use the Select_Reactor +static int opt_select_reactor = 0; + +// Make pipe readable in main() +static int write_to_pipe_in_main = 0; + +// Write some data to the pipe. This will cause handle_input to get +// called. +void +write_to_pipe (ACE_Pipe &pipe) +{ + char *data = "hello"; + int len = ACE_OS::strlen (data); + + int result = ACE::send (pipe.write_handle (), + data, + len); + ACE_ASSERT (result == len); +} + +// Simple handler class +class Handler : public ACE_Event_Handler +{ +public: + Handler (ACE_Pipe &pipe) + : pipe_ (pipe) + { + } + + ACE_HANDLE get_handle (void) const + { + return this->pipe_.read_handle (); + } + + int handle_close (ACE_HANDLE handle, + ACE_Reactor_Mask close_mask) + { + ACE_DEBUG ((LM_DEBUG, + "Handle closed called with mask = %d\n", + close_mask)); + return 0; + } + + int handle_input (ACE_HANDLE handle) + { + // Remove for reading + return -1; + } + + int handle_output (ACE_HANDLE handle) + { + // Write to the pipe; this causes handle_input to get called. + if (!write_to_pipe_in_main) + write_to_pipe (this->pipe_); + + // Remove for writing + return -1; + } + +protected: + ACE_Pipe &pipe_; +}; + +class Different_Handler : public Handler +{ +public: + + Different_Handler (ACE_Pipe &pipe) + : Handler (pipe) + { + } + + int handle_input (ACE_HANDLE handle) + { + // Remove for reading + int result = ACE_Reactor::instance ()->remove_handler (this, + ACE_Event_Handler::READ_MASK); + ACE_ASSERT (result == 0); + + return 0; + } + + int handle_output (ACE_HANDLE handle) + { + // Remove for writing + ACE_Reactor_Mask mask = ACE_Event_Handler::WRITE_MASK | ACE_Event_Handler::DONT_CALL; + int result = ACE_Reactor::instance ()->remove_handler (this, + mask); + ACE_ASSERT (result == 0); + + // Write to the pipe; this causes handle_input to get called. + if (!write_to_pipe_in_main) + write_to_pipe (this->pipe_); + + return 0; + } +}; + + +// +// Selection of which reactor should get created +// +void +create_reactor (void) +{ + ACE_Reactor_Impl *impl = 0; + + if (opt_wfmo_reactor) + { +#if defined (ACE_WIN32) && !defined (ACE_HAS_WINCE) + ACE_NEW (impl, + ACE_WFMO_Reactor); +#endif /* ACE_WIN32 */ + } + else if (opt_select_reactor) + ACE_NEW (impl, + ACE_Select_Reactor); + + ACE_Reactor *reactor = 0; + ACE_NEW (reactor, + ACE_Reactor (impl)); + ACE_Reactor::instance (reactor); +} + +int +main (int argc, char *argv[]) +{ + int result = 0; + + // Parse args + ACE_Get_Opt getopt (argc, argv, ASYS_TEXT ("swm"), 1); + for (int c; (c = getopt ()) != -1; ) + switch (c) + { + case 's': + opt_select_reactor = 1; + break; + case 'w': + opt_wfmo_reactor = 1; + break; + case 'm': + write_to_pipe_in_main = 1; + break; + } + + // Create pipes + ACE_Pipe pipe1, pipe2; + + result = pipe1.open (); + ACE_ASSERT (result == 0); + + result = pipe2.open (); + ACE_ASSERT (result == 0); + + // Create handlers + Handler handler (pipe1); + Different_Handler different_handler (pipe2); + + // Create reactor + create_reactor (); + + // Manage memory automagically. + auto_ptr<ACE_Reactor> reactor (ACE_Reactor::instance ()); + auto_ptr<ACE_Reactor_Impl> impl; + + // If we are using other that the default implementation, we must + // clean up. + if (opt_select_reactor || opt_wfmo_reactor) + impl = auto_ptr<ACE_Reactor_Impl> (ACE_Reactor::instance ()->implementation ()); + + // Register handlers + ACE_Reactor_Mask mask = + ACE_Event_Handler::READ_MASK | + ACE_Event_Handler::WRITE_MASK | + ACE_Event_Handler::EXCEPT_MASK; + + result = ACE_Reactor::instance ()->register_handler (&handler, + mask); + ACE_ASSERT (result == 0); + + result = ACE_Reactor::instance ()->register_handler (&different_handler, + mask); + ACE_ASSERT (result == 0); + + // Write to the pipe; this causes handle_input to get called. + if (write_to_pipe_in_main) + { + write_to_pipe (pipe1); + write_to_pipe (pipe2); + } + + // Note that handle_output will get called automatically since the + // pipe is writable! + + // Run for three seconds + ACE_Time_Value time (3); + ACE_Reactor::instance ()->run_event_loop (time); + + return 0; +} |