From 9f6f599d785fb4138e6a4d10e0c2c790dde36eb7 Mon Sep 17 00:00:00 2001 From: XMRig Date: Sun, 11 Nov 2018 03:18:56 +0700 Subject: [PATCH] Sync changes. --- CMakeLists.txt | 4 ++-- cmake/OpenSSL.cmake | 2 ++ src/App.cpp | 4 ++++ src/common/config/CommonConfig.cpp | 3 +++ src/common/config/ConfigLoader.cpp | 5 +++++ src/common/config/ConfigLoader.h | 9 ++++++--- src/core/Controller.cpp | 6 ++++++ src/core/Controller.h | 7 ++++--- 8 files changed, 32 insertions(+), 8 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 4d910e6e9..039bf418f 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -257,5 +257,5 @@ if (WITH_DEBUG_LOG) add_definitions(/DAPP_DEBUG) endif() -add_executable(${PROJECT_NAME} ${HEADERS} ${SOURCES} ${SOURCES_OS} ${SOURCES_CPUID} ${HEADERS_CRYPTO} ${SOURCES_CRYPTO} ${SOURCES_SYSLOG} ${HTTPD_SOURCES} ${TLS_SOURCES} ${XMRIG_ASM_SOURCES}) -target_link_libraries(${PROJECT_NAME} ${XMRIG_ASM_LIBRARY} ${OPENSSL_LIBRARIES} ${UV_LIBRARIES} ${MHD_LIBRARY} ${EXTRA_LIBS} ${CPUID_LIB}) +add_executable(${CMAKE_PROJECT_NAME} ${HEADERS} ${SOURCES} ${SOURCES_OS} ${SOURCES_CPUID} ${HEADERS_CRYPTO} ${SOURCES_CRYPTO} ${SOURCES_SYSLOG} ${HTTPD_SOURCES} ${TLS_SOURCES} ${XMRIG_ASM_SOURCES}) +target_link_libraries(${CMAKE_PROJECT_NAME} ${XMRIG_ASM_LIBRARY} ${OPENSSL_LIBRARIES} ${UV_LIBRARIES} ${MHD_LIBRARY} ${EXTRA_LIBS} ${CPUID_LIB}) diff --git a/cmake/OpenSSL.cmake b/cmake/OpenSSL.cmake index ed287e7e3..79731d6f7 100644 --- a/cmake/OpenSSL.cmake +++ b/cmake/OpenSSL.cmake @@ -20,4 +20,6 @@ else() set(TLS_SOURCES "") set(OPENSSL_LIBRARIES "") add_definitions(/DXMRIG_NO_TLS) + + set(CMAKE_PROJECT_NAME "${CMAKE_PROJECT_NAME}-notls") endif() diff --git a/src/App.cpp b/src/App.cpp index 134e4ef56..e3c4c222d 100644 --- a/src/App.cpp +++ b/src/App.cpp @@ -87,6 +87,10 @@ App::~App() int App::exec() { + if (m_controller->isDone()) { + return 0; + } + if (!m_controller->isReady()) { return 2; } diff --git a/src/common/config/CommonConfig.cpp b/src/common/config/CommonConfig.cpp index 94399d7d7..f2a001829 100644 --- a/src/common/config/CommonConfig.cpp +++ b/src/common/config/CommonConfig.cpp @@ -174,8 +174,11 @@ void xmrig::CommonConfig::printVersions() int length = snprintf(buf, sizeof buf, "CUDA/%d.%d ", cudaVersion / 1000, cudaVersion % 100); # else memset(buf, 0, 16); + +# if !defined(XMRIG_NO_HTTPD) || !defined(XMRIG_NO_TLS) int length = 0; # endif +# endif # if !defined(XMRIG_NO_TLS) && defined(OPENSSL_VERSION_TEXT) { diff --git a/src/common/config/ConfigLoader.cpp b/src/common/config/ConfigLoader.cpp index 484c2f8fb..0365e1515 100644 --- a/src/common/config/ConfigLoader.cpp +++ b/src/common/config/ConfigLoader.cpp @@ -50,6 +50,7 @@ #include "rapidjson/filereadstream.h" +bool xmrig::ConfigLoader::m_done = false; xmrig::ConfigWatcher *xmrig::ConfigLoader::m_watcher = nullptr; xmrig::IConfigCreator *xmrig::ConfigLoader::m_creator = nullptr; xmrig::IWatcherListener *xmrig::ConfigLoader::m_listener = nullptr; @@ -283,12 +284,16 @@ void xmrig::ConfigLoader::parseJSON(xmrig::IConfig *config, const struct option void xmrig::ConfigLoader::showUsage() { + m_done = true; + printf(usage); } void xmrig::ConfigLoader::showVersion() { + m_done = true; + printf(APP_NAME " " APP_VERSION "\n built on " __DATE__ # if defined(__clang__) diff --git a/src/common/config/ConfigLoader.h b/src/common/config/ConfigLoader.h index 64638af3d..840080f9f 100644 --- a/src/common/config/ConfigLoader.h +++ b/src/common/config/ConfigLoader.h @@ -21,8 +21,8 @@ * along with this program. If not, see . */ -#ifndef __CONFIGLOADER_H__ -#define __CONFIGLOADER_H__ +#ifndef XMRIG_CONFIGLOADER_H +#define XMRIG_CONFIGLOADER_H #include @@ -53,6 +53,8 @@ public: static IConfig *load(int argc, char **argv, IConfigCreator *creator, IWatcherListener *listener); static void release(); + static inline bool isDone() { return m_done; } + private: static bool getJSON(const char *fileName, rapidjson::Document &doc); static bool parseArg(IConfig *config, int key, const char *arg); @@ -60,6 +62,7 @@ private: static void showUsage(); static void showVersion(); + static bool m_done; static ConfigWatcher *m_watcher; static IConfigCreator *m_creator; static IWatcherListener *m_listener; @@ -68,4 +71,4 @@ private: } /* namespace xmrig */ -#endif /* __CONFIGLOADER_H__ */ +#endif /* XMRIG_CONFIGLOADER_H */ diff --git a/src/core/Controller.cpp b/src/core/Controller.cpp index 792ac9399..7a9b8284a 100644 --- a/src/core/Controller.cpp +++ b/src/core/Controller.cpp @@ -78,6 +78,12 @@ xmrig::Controller::~Controller() } +bool xmrig::Controller::isDone() const +{ + return ConfigLoader::isDone(); +} + + bool xmrig::Controller::isReady() const { return d_ptr->config && d_ptr->network; diff --git a/src/core/Controller.h b/src/core/Controller.h index 2c66af532..abb11ecfb 100644 --- a/src/core/Controller.h +++ b/src/core/Controller.h @@ -21,8 +21,8 @@ * along with this program. If not, see . */ -#ifndef __CONTROLLER_H__ -#define __CONTROLLER_H__ +#ifndef XMRIG_CONTROLLER_H +#define XMRIG_CONTROLLER_H #include "common/interfaces/IWatcherListener.h" @@ -46,6 +46,7 @@ public: Controller(); ~Controller(); + bool isDone() const; bool isReady() const; Config *config() const; int init(int argc, char **argv); @@ -61,4 +62,4 @@ private: } /* namespace xmrig */ -#endif /* __CONTROLLER_H__ */ +#endif /* XMRIG_CONTROLLER_H */