[ace-users] Svc Termination
JR Andreassen
janrune at io.com
Wed Jun 20 09:46:19 CDT 2007
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;
}
More information about the Ace-users
mailing list