Changes to attempt to silence bcc64x
[ACE_TAO.git] / ACE / tests / Bug_2368_Regression_Test.cpp
blobf3afd21436243f3135aa1790e7f3cecca41fe1fb
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 int handle_close (ACE_HANDLE, ACE_Reactor_Mask) override
24 ACE_DEBUG ((LM_DEBUG,
25 "Handle close called\n"));
26 handleA_close_called = true;
28 return 0;
31 int handle_signal (int, siginfo_t *, ucontext_t *) override
33 ACE_DEBUG ((LM_DEBUG,
34 "Handle signal called\n"));
36 return 0;
40 class My_HandlerB : public ACE_Event_Handler
42 public:
43 int handle_close (ACE_HANDLE, ACE_Reactor_Mask) override
45 ACE_DEBUG ((LM_DEBUG,
46 "Handle close called\n"));
47 handleB_close_called = true;
49 return 0;
52 int handle_signal (int, siginfo_t *, ucontext_t *) override
54 ACE_DEBUG ((LM_DEBUG,
55 "Handle signal called\n"));
57 return 0;
61 int
62 run_main (int, ACE_TCHAR *[])
64 ACE_START_TEST (ACE_TEXT ("Bug_2368_Regression_Test"));
66 My_HandlerA my_handlerA;
67 My_HandlerB my_handlerB;
69 // Set up an ACE signal handler.
70 if (ACE_Reactor::instance ()->register_handler
71 (SIGINT,
72 &my_handlerA) == -1)
73 ACE_ERROR ((LM_DEBUG,
74 ACE_TEXT ("%p\n"),
75 ACE_TEXT ("register_handlerA")));
77 if (ACE_Reactor::instance ()->register_handler
78 (SIGTERM,
79 &my_handlerB) == -1)
80 ACE_ERROR ((LM_DEBUG,
81 ACE_TEXT ("%p\n"),
82 ACE_TEXT ("register_handlerB")));
84 ACE_Sig_Action *new_disp = 0;
85 if (ACE_Reactor::instance ()->remove_handler
86 (SIGINT,
87 new_disp) == -1)
88 ACE_ERROR ((LM_DEBUG,
89 ACE_TEXT ("%p\n"),
90 ACE_TEXT ("remove_handlerB")));
92 if (ACE_Reactor::instance ()->close () == -1)
93 ACE_ERROR ((LM_ERROR,
94 ACE_TEXT ("%p\n"),
95 ACE_TEXT ("close")));
97 if (!handleA_close_called)
98 ACE_ERROR ((LM_ERROR,
99 ACE_TEXT ("Handle close hasn't been called for A.\n")));
101 if (!handleB_close_called)
102 ACE_ERROR ((LM_ERROR,
103 ACE_TEXT ("Handle close hasn't been called for B.\n")));
105 ACE_END_TEST;
107 return 0;