[ace-users] Svc Termination
JR Andreassen
janrune at io.com
Wed Jun 20 14:32:53 CDT 2007
Hi...
Yes that does the trick.
My intent is to terminate the service.
So that gives me the following sequence for terminating the Service:
I do a "broadcast" with a SIGTERM
=> calls: handle_signal(SIGTERM)
=> causes all SVC's to terminate their loop.
and does a join[wait()]
=> ACE_Service_Config::fini_svcs(); -> cleanup...
---------------------------------------------
Like such:
void SDI_ACENTService::handle_control (DWORD control_code)
{
if (control_code == SERVICE_CONTROL_SHUTDOWN
|| control_code == SERVICE_CONTROL_STOP)
{
report_status (SERVICE_STOP_PENDING);
SDI::GlobalDebug::Log("SDI_ACENTService control stop requested");
SDI::ACE_Utils::broadcastSignal(SIGTERM, 0);
ACE_Service_Config::fini_svcs();
ACE_Reactor::instance()->end_reactor_event_loop();
stop_ = 1;
}
else
{ super::handle_control (control_code);}
}
Thanks for the input.
JR
P.S. I have extended "ACE_NT_Service" to include "standard" registry
interface as well, if there is intrest I'll contribute it...
>>>Could you simply use ACE_Service_Config::fini_svcs() ?
>>>
>>>
>>I could try that....
>>But, that rises the question, should it be called from
>>ACE_NT_Service::stop_svc()
>>
>>
>
>If the ACE services should all be stopped when the NT/Windows service
>is, then yes.
>
>Note also, that when ACE::fini() is run, all the ACE services will be
>run down as well. I'm not sure if this is the situation you're in...
>
>-Steve
>
>
>
>>>>-----Original Message-----
>>>>From: ace-users-bounces at cse.wustl.edu
>>>>[mailto:ace-users-bounces at cse.wustl.edu] On Behalf Of JR
>>>>
>>>>
>Andreassen
>
>
>>>>Sent: Wednesday, June 20, 2007 10:46 AM
>>>>Cc: ace-users at cse.wustl.edu
>>>>Subject: [ace-users] Svc Termination
>>>>
>>>>
>>>> ACE VERSION: 5.5.8
>>>> HOST MACHINE and OPERATING SYSTEM: Win XP, sp1
>>>> TARGET MACHINE and OPERATING SYSTEM, if different from HOST:
>>>>
>>>> COMPILER NAME AND VERSION: VC++ 8.0(MSVC 2005) & VC6
>>>>
>>>> CONTENTS OF $ACE_ROOT/ace/config.h
>>>>#if !defined (_WIN32_WCE)
>>>># define ACE_ENABLE_SWAP_ON_WRITE
>>>>//# define ACE_DISABLE_SWAP_ON_READ
>>>># define ACE_DISABLE_WIN32_ERROR_WINDOWS
>>>># define ACE_HAS_STANDARD_CPP_LIBRARY 1
>>>>#endif
>>>>#include "ace/config-win32.h"
>>>>
>>>>
>>>> SYNOPSIS:
>>>>What is the appropriate way to shutdown service.
>>>>
>>>> DESCRIPTION:
>>>>I have a set of servicees running. I've had a lot of problems
>>>>shutting
>>>>them down gracefully.
>>>>After 5.5.6 things changed for the better, thanks for fixing the
>>>>
>>>>
>>>>
>>>>
>>>bugs
>>>
>>>
>>>
>>>
>>>>that was driving me mad searching :)
>>>>
>>>>So, currently I broadcast a MB_HANGUP message then terminate(see
>>>>broadcastSignal).
>>>>Then :
>>>> ACE_Reactor::instance()->end_reactor_event_loop();
>>>>
>>>>My problem is that it doesn't look like fini and deallocation
>>>>
>>>>
>don't
>
>
>>>>allways happen.
>>>>
>>>>So, my question is this....
>>>>What is the proper sequence of events ???
>>>>
>>>>I appriciate any help/insight or pointers.
>>>> Thanks
>>>> JR
>>>>
>>>>// --------------------------------------------------------------
>>>>/**
>>>>* Broadcast Signal(sig) to all tasks
>>>>* @param sig Signal to broadcast.
>>>>* @param ignored_suspended Flag to determine wether to ignore
>>>>suspended tasks.
>>>>* @return int Number ot tasks notified.
>>>>*/
>>>>int broadcastSignal(int signum, int ignored_suspended)
>>>>{ int retVal = 0;
>>>> ACE_Service_Object* svoTest = NULL;
>>>> ACE_Event_Handler* handler = NULL;
>>>> ACE_Task_Base* taskbase = NULL;
>>>> ACE_Service_Repository* svcs_repository =
>>>>ACE_Service_Repository::instance();
>>>> const ACE_Service_Type_Impl * srpI = NULL;
>>>> const ACE_Service_Type* srp = NULL;
>>>> if(svcs_repository != NULL)
>>>> {
>>>> ACE_Service_Repository_Iterator repIter(*svcs_repository,
>>>>ignored_suspended);
>>>> for(;repIter.next(srp) > 0;repIter.advance())
>>>> {
>>>> srpI = srp->type();
>>>> if(!ISNULL(srpI))
>>>> {
>>>> svoTest =
>>>>static_cast<ACE_Service_Object*>(srpI->object());
>>>> if(!ISNULL(svoTest))
>>>> {
>>>> handler =
>>>>dynamic_cast<ACE_Event_Handler*>(svoTest);
>>>> if(!ISNULL(handler))
>>>> { handler->handle_signal(signum);}
>>>> Sleep(0);
>>>> retVal++;
>>>> }
>>>> }
>>>> }
>>>> Sleep(0);
>>>> }
>>>> return retVal;
>>>>}
>>>>
>>>>
>>>>_______________________________________________
>>>>ace-users mailing list
>>>>ace-users at mail.cse.wustl.edu
>>>>http://mail.cse.wustl.edu/mailman/listinfo/ace-users
>>>>
>>>>
>>>>
>>>>
>>>>
>>>
>>>
>>>
>>>
>>>
>>>
>
>
>
>
>
>
More information about the Ace-users
mailing list