diff options
author | Gluzskiy Alexandr <sss@sss.chaoslab.ru> | 2015-09-15 12:49:00 +0300 |
---|---|---|
committer | Gluzskiy Alexandr <sss@sss.chaoslab.ru> | 2015-09-15 12:49:00 +0300 |
commit | f4750dc7ca9ce56c54352c03bb40affe1a64c315 (patch) | |
tree | e5ff58ae92b0c49f5624644611ea05312eebe1ed /server/src/main.cpp | |
parent | 1d6ced38a89547aaf2cc3745876360f0e5086474 (diff) |
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)
Diffstat (limited to 'server/src/main.cpp')
-rw-r--r-- | server/src/main.cpp | 33 |
1 files changed, 30 insertions, 3 deletions
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") |