From f4750dc7ca9ce56c54352c03bb40affe1a64c315 Mon Sep 17 00:00:00 2001 From: Gluzskiy Alexandr Date: Tue, 15 Sep 2015 12:49:00 +0300 Subject: client-qt: implemented handler for SERVER_DOWNLOAD_INFO_REPLY server: api: removed core_id field from download_internal_s as it always used for index in download map some useful coments core: improoved signal handler a bit fiexd bug in core_api metadata related functions (metadata_set, metadata_get, metadata_remove), now thay returning correct data basic implementation of CLIENT_DOWNLOAD_ADD handler basic implementation of module unloading curl_downloader_module: implemented metadata storing some sanity checks curl_download structure refactored a bit (simplification) --- server/src/main.cpp | 33 ++++++++++++++++++++++++++++++--- 1 file changed, 30 insertions(+), 3 deletions(-) (limited to 'server/src/main.cpp') diff --git a/server/src/main.cpp b/server/src/main.cpp index 09b0b62..214b6b5 100644 --- a/server/src/main.cpp +++ b/server/src/main.cpp @@ -52,15 +52,42 @@ server *serv = nullptr; //TODO: "core" config section architecture, define base settings -void sigint_handler(int sig) +void on_exit() { + serv->terminate(); bpt::write_info(runtime_config.config_file_path, runtime_config.config_file); //save config on sigint - exit(0); + for(auto m : modules->get_downloader_modules()) + delete m; + for(auto m : modules->get_metadata_modules()) + delete m; +} + +void sig_handler(int sig) +{ + switch(sig) + { + default: + { + on_exit(); + exit(0); + } + break; + } } extern "C" int main(int argc, char *argv[]) { - signal(SIGINT, sigint_handler); + //handle signals + signal(SIGINT, sig_handler); + signal(SIGTERM, sig_handler); + signal(SIGABRT, sig_handler); + + //this will not work + signal(SIGKILL, sig_handler); + signal(SIGSTOP, sig_handler); + + + bpo::options_description desc("Available commands and options"); desc.add_options() ("help,h", "this message") -- cgit v1.2.3