Doxygen changes
[ACE_TAO.git] / ACE / tests / Bug_2368_Regression_Test.cpp
blob8047998800611c0b4e0b10037372c2474ee15310
1 /**
2 * @file Bug_2368_Regression_Test.cpp
4 * Reproduces the problems reported in bug 2368:
5 * http://bugzilla.dre.vanderbilt.edu/show_bug.cgi?id=2368
7 * @author Johnny Willemsen <jwillemsen@remedy.nl>
8 */
10 #include "test_config.h"
11 #include "ace/Service_Config.h"
12 #include "ace/Reactor.h"
13 #include "ace/Log_Msg.h"
14 #include "ace/Signal.h"
16 static bool handleA_close_called = false;
17 static bool handleB_close_called = false;
19 class My_HandlerA : public ACE_Event_Handler
21 public:
22 virtual int handle_close (ACE_HANDLE,
23 ACE_Reactor_Mask)
25 ACE_DEBUG ((LM_DEBUG,
26 "Handle close called\n"));
27 handleA_close_called = true;
29 return 0;
32 virtual int handle_signal (int,
33 siginfo_t *,
34 ucontext_t *)
36 ACE_DEBUG ((LM_DEBUG,
37 "Handle signal called\n"));
39 return 0;
43 class My_HandlerB : public ACE_Event_Handler
45 public:
46 virtual int handle_close (ACE_HANDLE,
47 ACE_Reactor_Mask)
49 ACE_DEBUG ((LM_DEBUG,
50 "Handle close called\n"));
51 handleB_close_called = true;
53 return 0;
56 virtual int handle_signal (int,
57 siginfo_t *,
58 ucontext_t *)
60 ACE_DEBUG ((LM_DEBUG,
61 "Handle signal called\n"));
63 return 0;
67 int
68 run_main (int, ACE_TCHAR *[])
70 ACE_START_TEST (ACE_TEXT ("Bug_2368_Regression_Test"));
72 My_HandlerA my_handlerA;
73 My_HandlerB my_handlerB;
75 // Set up an ACE signal handler.
76 if (ACE_Reactor::instance ()->register_handler
77 (SIGINT,
78 &my_handlerA) == -1)
79 ACE_ERROR ((LM_DEBUG,
80 ACE_TEXT ("%p\n"),
81 ACE_TEXT ("register_handlerA")));
83 if (ACE_Reactor::instance ()->register_handler
84 (SIGTERM,
85 &my_handlerB) == -1)
86 ACE_ERROR ((LM_DEBUG,
87 ACE_TEXT ("%p\n"),
88 ACE_TEXT ("register_handlerB")));
90 ACE_Sig_Action *new_disp = 0;
91 if (ACE_Reactor::instance ()->remove_handler
92 (SIGINT,
93 new_disp) == -1)
94 ACE_ERROR ((LM_DEBUG,
95 ACE_TEXT ("%p\n"),
96 ACE_TEXT ("remove_handlerB")));
98 if (ACE_Reactor::instance ()->close () == -1)
99 ACE_ERROR ((LM_ERROR,
100 ACE_TEXT ("%p\n"),
101 ACE_TEXT ("close")));
103 if (!handleA_close_called)
104 ACE_ERROR ((LM_ERROR,
105 ACE_TEXT ("Handle close hasn't been called for A.\n")));
107 if (!handleB_close_called)
108 ACE_ERROR ((LM_ERROR,
109 ACE_TEXT ("Handle close hasn't been called for B.\n")));
111 ACE_END_TEST;
113 return 0;