diff options
Diffstat (limited to 'core/main.cpp')
-rw-r--r-- | core/main.cpp | 49 |
1 files changed, 30 insertions, 19 deletions
diff --git a/core/main.cpp b/core/main.cpp index 64c14d5..4a71738 100644 --- a/core/main.cpp +++ b/core/main.cpp @@ -22,10 +22,32 @@ boost::mutex plugin_list_mutex; std::list<service*> services; boost::mutex service_list_mutex; ACE_Log_Msg logger; +bool halt_requested = false; PLUGINLINK pluglink = {&CreateServiceFunction, &CallService, &ServiceExists}; +int on_exit() +{ + plugin_list_mutex.lock(); + service_list_mutex.lock(); + if(!services.empty()) + { + std::list<service*>::iterator end = services.end(); + for(std::list<service*>::iterator i = services.begin(); i != end; ++i) + delete *i; + services.clear(); + } + if(!plugins.empty()) + { + std::list<plugin*>::iterator end = plugins.end(); + for(std::list<plugin*>::iterator i = plugins.begin(); i != end; ++i) + delete *i; + plugins.clear(); + } + return 0; +} + #ifdef _WIN32 HINSTANCE hInst; int __stdcall WinMain( __in HINSTANCE hInstance, __in_opt HINSTANCE hPrevInstance, __in_opt LPSTR lpCmdLine, __in int nShowCmd ) @@ -47,27 +69,16 @@ int ACE_MAIN(int argc, char *argv[]) while(true) { logger.log(LM_DEBUG, "Main threas sleeping...\n"); - boost::this_thread::sleep(boost::posix_time::seconds(10)); //warning from compiller on this string can be safely ignored + boost::this_thread::sleep(boost::posix_time::seconds(5)); + if(halt_requested) + break; } return 0; } - -int on_exit() +void terminate() { - if(!services.empty()) - { - std::list<service*>::iterator end = services.end(); - for(std::list<service*>::iterator i = services.begin(); i != end; ++i) - delete *i; - services.clear(); - } - if(!plugins.empty()) - { - std::list<plugin*>::iterator end = plugins.end(); - for(std::list<plugin*>::iterator i = plugins.begin(); i != end; ++i) - delete *i; - plugins.clear(); - } - return 0; -}
\ No newline at end of file + if(on_exit()) + logger.log(LM_DEBUG, "Something bad happened on exit"); +} + |