From b4bfdf2e25ac3a7b081ee8794f20f8936f45c2ef Mon Sep 17 00:00:00 2001 From: csoler Date: Fri, 30 Aug 2019 22:09:47 +0200 Subject: [PATCH] fixed shutdown callback issue in retroshare-service.cc --- libretroshare/src/rsserver/rsinit.cc | 1 - retroshare-service/src/retroshare-service.cc | 7 +++++-- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/libretroshare/src/rsserver/rsinit.cc b/libretroshare/src/rsserver/rsinit.cc index a3b51238a..ed2e9accf 100644 --- a/libretroshare/src/rsserver/rsinit.cc +++ b/libretroshare/src/rsserver/rsinit.cc @@ -22,7 +22,6 @@ /// RetroShare initialization and login API implementation #include -#include #include #ifndef WINDOWS_SYS diff --git a/retroshare-service/src/retroshare-service.cc b/retroshare-service/src/retroshare-service.cc index fc85a4118..6e8b0d9d5 100644 --- a/retroshare-service/src/retroshare-service.cc +++ b/retroshare-service/src/retroshare-service.cc @@ -284,8 +284,11 @@ int main(int argc, char* argv[]) if(jsonApiServer) jsonApiServer->authorizeToken("webui:"+webui_pass1); - while(true) - sleep(1); + std::atomic keepRunning = true; + rsControl->setShutdownCallback([&](int){keepRunning = false;}); + + while(keepRunning) + std::this_thread::sleep_for(std::chrono::seconds(5)); #endif }