Merge pull request #1551 from DOCGroup/plm_jira_333
[ACE_TAO.git] / TAO / examples / Callback_Quoter / Consumer_Signal_Handler.cpp
blob9298cad5ce2d63726d9aceb7ad4be098721dba4c
1 /* -*- C++ -*- */
3 //=============================================================================
4 /**
5 * @file Consumer_Signal_Handler.cpp
7 * Implementation of the Consumer_Signal_Handler class.
9 * @author Kirthika Parameswaran <kirthika@cs.wustl.edu>
11 //=============================================================================
14 #include "Consumer_Signal_Handler.h"
16 Consumer_Signal_Handler::Consumer_Signal_Handler (Consumer_Handler *consumer_handler)
17 : consumer_handler_ (consumer_handler)
21 Consumer_Signal_Handler:: ~Consumer_Signal_Handler (void)
25 // Method to handle the ^C signal.
26 int
27 Consumer_Signal_Handler::handle_signal (int /* signum */,
28 siginfo_t*,
29 ucontext_t*)
31 ACE_DEBUG ((LM_DEBUG,
32 " Exiting on receiving ^C\n"));
34 quit_on_signal ();
36 return 0;
39 // Method called before the Event_Handler dies.
40 int
41 Consumer_Signal_Handler::handle_close (ACE_HANDLE,
42 ACE_Reactor_Mask)
44 // End of the signal handler.
45 delete this;
47 return 0;
50 int
51 Consumer_Signal_Handler::quit_on_signal (void)
53 // Only if the consumer is registered and wants to shut down, its
54 // necessary to unregister and then shutdown.
57 try
59 if (consumer_handler_->unregistered_ != 1
60 && consumer_handler_->registered_ == 1)
62 this->consumer_handler_->server_->unregister_callback
63 (this->consumer_handler_->consumer_var_.in ());
64 ACE_DEBUG ((LM_DEBUG,
65 "Consumer Unregistered\n"));
67 this->consumer_handler_->consumer_servant_->shutdown ();
69 catch (const CORBA::Exception& ex)
71 ex._tao_print_exception (
72 "Consumer_Input_Handler::quit_consumer_process()");
73 return -1;
76 return 0;