diff options
author | Henri Herscher <henri@oreka.org> | 2005-11-15 04:19:31 +0000 |
---|---|---|
committer | Henri Herscher <henri@oreka.org> | 2005-11-15 04:19:31 +0000 |
commit | 7653151cb08cfa40eec22e7aac3068b009207bc8 (patch) | |
tree | c41e2f1bbf73001791248fb18d842a01978ad0e8 /orkaudio/OrkAudio.cpp | |
parent | 61cb474c09cce3a667774c4f4eef093c2025f324 (diff) |
Improvements in the shutdown procedure (NT service does not crash on exit anymore, give two seconds to threads to exit properly).
git-svn-id: https://oreka.svn.sourceforge.net/svnroot/oreka/trunk@44 09dcff7a-b715-0410-9601-b79a96267cd0
Diffstat (limited to 'orkaudio/OrkAudio.cpp')
-rw-r--r-- | orkaudio/OrkAudio.cpp | 29 |
1 files changed, 26 insertions, 3 deletions
diff --git a/orkaudio/OrkAudio.cpp b/orkaudio/OrkAudio.cpp index 45a1434..75e1140 100644 --- a/orkaudio/OrkAudio.cpp +++ b/orkaudio/OrkAudio.cpp @@ -42,9 +42,16 @@ void StopHandler() serviceStop = true; } +#ifdef WIN32 +long ExceptionFilter(struct _EXCEPTION_POINTERS *ptr) +{ + return EXCEPTION_CONTINUE_SEARCH; +} +#endif + void MainThread() { - LogManagerSingleton::instance()->Initialize(); + OrkLogManagerSingleton::instance()->Initialize(); LOG4CXX_INFO(LOG.rootLog, CStdString("\n\nOrkAudio service starting\n")); // Initialize object factory and register existing objects @@ -100,11 +107,27 @@ void MainThread() } //ACE_Thread_Manager::instance ()->wait (); - while(serviceStop == false) + while(!DaemonSingleton::instance()->IsStopping()) { ACE_OS::sleep(1); } - LOG4CXX_INFO(LOG.rootLog, CStdString("Stopping service")); + + CapturePluginProxySingleton::instance()->Shutdown(); + + // Wait that all ACE threads have returned + //ACE_Thread_Manager::instance ()->wait (); + ACE_OS::sleep(2); + + //***** This is to avoid an exception when NT service exiting + //***** Need to find out the real problem and fix +#ifdef WIN32 + SetErrorMode(SEM_FAILCRITICALERRORS | SEM_NOGPFAULTERRORBOX); + SetUnhandledExceptionFilter((LPTOP_LEVEL_EXCEPTION_FILTER)ExceptionFilter); +#endif + //***** + + LOG4CXX_INFO(LOG.rootLog, CStdString("Service stopped")); + OrkLogManagerSingleton::instance()->Shutdown(); } |