From b662cb77a4b8d0f80df348f4799a8164530cb9f6 Mon Sep 17 00:00:00 2001 From: XMRig <support@xmrig.com> Date: Fri, 9 Mar 2018 01:47:44 +0700 Subject: [PATCH] Revert changes in Api class, single threaded http server will not be included in 2.5 release. --- src/api/Api.cpp | 14 ++++++++++++-- src/api/Api.h | 3 ++- 2 files changed, 14 insertions(+), 3 deletions(-) diff --git a/src/api/Api.cpp b/src/api/Api.cpp index 98d441c13..729ebccdd 100644 --- a/src/api/Api.cpp +++ b/src/api/Api.cpp @@ -4,7 +4,7 @@ * Copyright 2014 Lucas Jones <https://github.com/lucasjones> * Copyright 2014-2016 Wolf9466 <https://github.com/OhGodAPet> * Copyright 2016 Jay D Dee <jayddee246@gmail.com> - * Copyright 2016-2018 XMRig <support@xmrig.com> + * Copyright 2016-2017 XMRig <support@xmrig.com> * * * This program is free software: you can redistribute it and/or modify @@ -29,10 +29,12 @@ ApiState *Api::m_state = nullptr; +uv_mutex_t Api::m_mutex; bool Api::start() { + uv_mutex_init(&m_mutex); m_state = new ApiState(); return true; @@ -51,7 +53,11 @@ char *Api::get(const char *url, int *status) return nullptr; } - return m_state->get(url, status); + uv_mutex_lock(&m_mutex); + char *buf = m_state->get(url, status); + uv_mutex_unlock(&m_mutex); + + return buf; } @@ -61,7 +67,9 @@ void Api::tick(const Hashrate *hashrate) return; } + uv_mutex_lock(&m_mutex); m_state->tick(hashrate); + uv_mutex_unlock(&m_mutex); } @@ -71,5 +79,7 @@ void Api::tick(const NetworkState &network) return; } + uv_mutex_lock(&m_mutex); m_state->tick(network); + uv_mutex_unlock(&m_mutex); } diff --git a/src/api/Api.h b/src/api/Api.h index 1f91b382f..72c65c3c0 100644 --- a/src/api/Api.h +++ b/src/api/Api.h @@ -4,7 +4,7 @@ * Copyright 2014 Lucas Jones <https://github.com/lucasjones> * Copyright 2014-2016 Wolf9466 <https://github.com/OhGodAPet> * Copyright 2016 Jay D Dee <jayddee246@gmail.com> - * Copyright 2016-2018 XMRig <support@xmrig.com> + * Copyright 2016-2017 XMRig <support@xmrig.com> * * * This program is free software: you can redistribute it and/or modify @@ -45,6 +45,7 @@ public: private: static ApiState *m_state; + static uv_mutex_t m_mutex; }; #endif /* __API_H__ */