From 0d0c10df11a11ea12518eed6913541b8ef7ab8ed Mon Sep 17 00:00:00 2001 From: jinhai Date: Wed, 15 May 2019 20:22:04 +0800 Subject: [PATCH] Update license check Former-commit-id: ab88deb5aaeadda3626106a3a4cf3600131f528e --- cpp/CMakeLists.txt | 9 +++++---- cpp/src/license/LicenseCheck.cpp | 5 ++--- cpp/src/license/LicenseCheck.h | 1 - cpp/src/server/Server.cpp | 6 ++---- 4 files changed, 9 insertions(+), 12 deletions(-) diff --git a/cpp/CMakeLists.txt b/cpp/CMakeLists.txt index c0eccae0ed..00a206484f 100644 --- a/cpp/CMakeLists.txt +++ b/cpp/CMakeLists.txt @@ -45,14 +45,15 @@ endif () if(CMAKE_BUILD_TYPE STREQUAL "Release") set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -O3 -fPIC -DELPP_THREAD_SAFE") - if (GPU_VERSION STREQUAL "ON") - set(ENABLE_LICENSE "ON") - add_definitions("-DENABLE_LICENSE") - endif () else() set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -O0 -g -fPIC -DELPP_THREAD_SAFE") endif() +if (GPU_VERSION STREQUAL "ON") + set(ENABLE_LICENSE "ON") + add_definitions("-DENABLE_LICENSE") +endif () + set(CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake/Modules/" ${CMAKE_MODULE_PATH}) set(VECWISE_ENGINE_INCLUDE ${PROJECT_SOURCE_DIR}/include) diff --git a/cpp/src/license/LicenseCheck.cpp b/cpp/src/license/LicenseCheck.cpp index ca8fb4f930..4ea29663cf 100644 --- a/cpp/src/license/LicenseCheck.cpp +++ b/cpp/src/license/LicenseCheck.cpp @@ -74,7 +74,7 @@ LicenseCheck::AlterFile(const std::string &license_file_path, { exit(1); } - printf("---runing---\n"); +// printf("---runing---\n"); pt->expires_at(pt->expires_at() + boost::posix_time::hours(1)); pt->async_wait(boost::bind(AlterFile, license_file_path, boost::asio::placeholders::error, pt)); return SERVER_SUCCESS; @@ -83,8 +83,7 @@ LicenseCheck::AlterFile(const std::string &license_file_path, ServerError LicenseCheck::StartCountingDown(const std::string &license_file_path) { - - if (!LicenseLibrary::IsFileExistent(license_file_path)) return SERVER_LICENSE_FILE_NOT_EXIST; + if (!LicenseLibrary::IsFileExistent(license_file_path)) exit(1); boost::asio::io_service io; boost::asio::deadline_timer t(io, boost::posix_time::hours(1)); t.async_wait(boost::bind(AlterFile, license_file_path, boost::asio::placeholders::error, &t)); diff --git a/cpp/src/license/LicenseCheck.h b/cpp/src/license/LicenseCheck.h index 9a22f57f5a..0fd1d87f35 100644 --- a/cpp/src/license/LicenseCheck.h +++ b/cpp/src/license/LicenseCheck.h @@ -36,7 +36,6 @@ class LicenseCheck { static ServerError StartCountingDown(const std::string &license_file_path); - private: }; diff --git a/cpp/src/server/Server.cpp b/cpp/src/server/Server.cpp index 8c79c5a215..3f51929baf 100644 --- a/cpp/src/server/Server.cpp +++ b/cpp/src/server/Server.cpp @@ -160,10 +160,8 @@ Server::Start() { exit(1); } - if(server::LicenseCheck::StartCountingDown(license_file_path) != SERVER_SUCCESS) { - SERVER_LOG_ERROR << "License counter start error"; - exit(1); - } + std::thread counting_down(&server::LicenseCheck::StartCountingDown, license_file_path); + counting_down.detach(); #endif // Handle Signal