summaryrefslogtreecommitdiff
path: root/examples/ASX/CCM_App/SC_Server.cpp
diff options
context:
space:
mode:
authorcbeaulac <cbeaulac@ae88bc3d-4319-0410-8dbf-d08b4c9d3795>2010-04-19 17:36:05 +0000
committercbeaulac <cbeaulac@ae88bc3d-4319-0410-8dbf-d08b4c9d3795>2010-04-19 17:36:05 +0000
commitafdde46ad84360164deaa75bce80c6ed2f232f42 (patch)
tree7546b7f5fda1401ec9995c3d14e99a9b45ee6083 /examples/ASX/CCM_App/SC_Server.cpp
parentcec172abb326be14f96ebf06a1ae48eee91c3e48 (diff)
downloadATCD-afdde46ad84360164deaa75bce80c6ed2f232f42.tar.gz
Mon Apr 19 17:34:04 UTC 2010 Chad Beaulac <chad@objectivesolutions.com
* ace/Service_Repository.cpp Modified ASR::fini to print debug info for empty service entries and handle empty service entries. This fixes the ASR remove functionality that was one of the reasons SC_Server was crashing at shutdown. * examples/ASX/CCM_App/SC_Server.cpp Removed ACE_Sig_Adapter shutdown_handler. Registered SIGINT and SIGQUIT handler for Event_Handler so it could call eh->remove_std_in_handler() to prevent SEGV at shutdown when CTRL-C was used to shutdown. This fixes Bugzilla #2916 and #3205. I'll create another patch for #3334 after this commit.
Diffstat (limited to 'examples/ASX/CCM_App/SC_Server.cpp')
-rw-r--r--examples/ASX/CCM_App/SC_Server.cpp36
1 files changed, 32 insertions, 4 deletions
diff --git a/examples/ASX/CCM_App/SC_Server.cpp b/examples/ASX/CCM_App/SC_Server.cpp
index c2e644fe2b4..0199451fdd3 100644
--- a/examples/ASX/CCM_App/SC_Server.cpp
+++ b/examples/ASX/CCM_App/SC_Server.cpp
@@ -10,7 +10,7 @@
#include "ace/Reactor.h"
#include "ace/Sig_Adapter.h"
-ACE_RCSID(CCM_App, SC_Server, "$Id$")
+ACE_RCSID (CCM_App, SC_Server, "$Id$")
class Event_Handler : public ACE_Event_Handler
{
@@ -18,8 +18,26 @@ public:
virtual int handle_input (ACE_HANDLE handle);
virtual int handle_close (ACE_HANDLE,
ACE_Reactor_Mask);
+
+ virtual int handle_signal (int signum,
+ siginfo_t *,
+ ucontext_t *);
};
+
+// @@ Note that this code is not portable to all OS platforms since
+// it does print statements within the signal handler.
+
+int
+Event_Handler::handle_signal (int signum,
+ siginfo_t *,
+ ucontext_t *)
+{
+ if (signum == SIGINT || signum == SIGQUIT)
+ return -1;
+ return 0;
+}
+
int
Event_Handler::handle_input (ACE_HANDLE handle)
{
@@ -35,7 +53,7 @@ Event_Handler::handle_input (ACE_HANDLE handle)
else if (ACE_OS::write (ACE_STDOUT, buf, n) != n)
ACE_ERROR_RETURN ((LM_DEBUG,
ACE_TEXT ("%p\n"), ACE_TEXT ("write failed")),
- -1);
+ -1);
else
return 0;
}
@@ -45,6 +63,8 @@ Event_Handler::handle_close (ACE_HANDLE, ACE_Reactor_Mask)
{
ACE_DEBUG ((LM_DEBUG,
ACE_TEXT ("closing Event_Handler\n")));
+ //ACE_Reactor::instance ()->remove_handler (this,ACE_Event_Handler::ALL_EVENTS_MASK);
+ this->remove_stdin_handler (ACE_Reactor::instance (),ACE_Thread_Manager::instance ());
ACE_Reactor::instance ()->end_reactor_event_loop ();
return 0;
}
@@ -71,8 +91,16 @@ ACE_TMAIN (int argc, ACE_TCHAR *argv[])
ACE_TEXT ("%p\n%a"),
ACE_TEXT ("open"),
1));
- // Perform logging service until we receive SIGINT.
+ else
+ {
+ ACE_Reactor::instance ()->register_handler (SIGQUIT, &handler);
+ ACE_Reactor::instance ()->register_handler (SIGINT, &handler);
+ ACE_Reactor::instance ()->run_reactor_event_loop ();
+
+ ACE_DEBUG ((LM_DEBUG,
+ ACE_TEXT ("SC_Server exiting\n")));
- ACE_Reactor::instance ()->run_reactor_event_loop ();
+ loggerd.fini_svcs ();
+ }
return 0;
}