From c5e961fd8dc561384c7cb833d10ddf369de5680c Mon Sep 17 00:00:00 2001 From: Thulinma Date: Tue, 9 May 2017 09:58:19 +0200 Subject: [PATCH] Added exitdelay in licensing system --- src/controller/controller.cpp | 6 ++++++ src/controller/controller_license.cpp | 4 ++++ src/controller/controller_license.h | 1 + 3 files changed, 11 insertions(+) diff --git a/src/controller/controller.cpp b/src/controller/controller.cpp index 6dd27c1b..e29415e4 100644 --- a/src/controller/controller.cpp +++ b/src/controller/controller.cpp @@ -429,6 +429,12 @@ int main_loop(int argc, char ** argv){ //give everything some time to print messages Util::wait(100); std::cout << "Killed all processes, wrote config to disk. Exiting." << std::endl; + if (Controller::exitDelay){ + std::cout << "Delaying shutdown by " << Controller::exitDelay << " seconds, on license server request..." << std::endl; + while (Controller::exitDelay--){ + Util::wait(1000); + } + } if (Controller::restarting){ return 42; } diff --git a/src/controller/controller_license.cpp b/src/controller/controller_license.cpp index 6fa2a0eb..3a5fc964 100644 --- a/src/controller/controller_license.cpp +++ b/src/controller/controller_license.cpp @@ -13,6 +13,7 @@ namespace Controller{ + uint64_t exitDelay = 0; static JSON::Value currentLicense; static uint64_t lastCheck = 0; @@ -67,6 +68,9 @@ namespace Controller{ INFO_MSG("Checking license time"); if(!isLicensed()){ FAIL_MSG("Not licensed, shutting down"); + if (currentLicense.isMember("delay") && currentLicense["delay"].asInt()){ + exitDelay = currentLicense["delay"].asInt(); + } kill(getpid(), SIGINT); conf.is_active = false; return false; diff --git a/src/controller/controller_license.h b/src/controller/controller_license.h index c5d97606..05020b53 100644 --- a/src/controller/controller_license.h +++ b/src/controller/controller_license.h @@ -2,6 +2,7 @@ #include namespace Controller{ + extern uint64_t exitDelay; const JSON::Value & getLicense(); void initLicense();