Fixed windows build
This commit is contained in:
parent
0dc02587c1
commit
627321b6cc
9 changed files with 84 additions and 28 deletions
13
src/App.cpp
13
src/App.cpp
|
@ -25,7 +25,6 @@
|
|||
|
||||
#include <stdlib.h>
|
||||
#include <uv.h>
|
||||
#include <zconf.h>
|
||||
|
||||
#include "api/Api.h"
|
||||
#include "App.h"
|
||||
|
@ -111,7 +110,9 @@ App::~App()
|
|||
# endif
|
||||
|
||||
# ifndef XMRIG_NO_CC
|
||||
delete m_ccclient;
|
||||
if (m_ccclient) {
|
||||
delete m_ccclient;
|
||||
}
|
||||
# endif
|
||||
}
|
||||
|
||||
|
@ -146,7 +147,11 @@ int App::start()
|
|||
# endif
|
||||
|
||||
# ifndef XMRIG_NO_CC
|
||||
m_ccclient = new CCClient(m_options);
|
||||
if (m_options->ccUrl()) {
|
||||
m_ccclient = new CCClient(m_options);
|
||||
} else {
|
||||
LOG_WARN("Please configure CC-Url and restart. CC feature is now deactivated.");
|
||||
}
|
||||
# endif
|
||||
|
||||
Workers::start(m_options->affinity(), m_options->priority());
|
||||
|
@ -156,7 +161,7 @@ int App::start()
|
|||
const int r = uv_run(uv_default_loop(), UV_RUN_DEFAULT);
|
||||
uv_loop_close(uv_default_loop());
|
||||
|
||||
return m_restart ? ERESTART : r;
|
||||
return m_restart ? EINTR : r;
|
||||
}
|
||||
|
||||
void App::onConsoleCommand(char command)
|
||||
|
|
|
@ -22,7 +22,6 @@
|
|||
*/
|
||||
|
||||
|
||||
#include <zconf.h>
|
||||
#include "Console.h"
|
||||
#include "interfaces/IConsoleListener.h"
|
||||
|
||||
|
|
|
@ -307,7 +307,6 @@ Options::Options(int argc, char **argv) :
|
|||
return;
|
||||
}
|
||||
#else
|
||||
|
||||
#ifndef XMRIG_NO_CC
|
||||
if (!m_daemonized) {
|
||||
fprintf(stderr, "\"" APP_ID "\" is compiled with CC support, please start the daemon instead.\n");
|
||||
|
|
|
@ -22,11 +22,16 @@
|
|||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include <zconf.h>
|
||||
#include <fstream>
|
||||
#include <3rdparty/rapidjson/stringbuffer.h>
|
||||
#include <3rdparty/rapidjson/prettywriter.h>
|
||||
|
||||
#if _WIN32
|
||||
# include "winsock2.h"
|
||||
#else
|
||||
# include "unistd.h"
|
||||
#endif
|
||||
|
||||
#include "CCClient.h"
|
||||
#include "App.h"
|
||||
#include "ControlCommand.h"
|
||||
|
@ -42,6 +47,8 @@ uv_mutex_t CCClient::m_mutex;
|
|||
CCClient::CCClient(const Options *options)
|
||||
: m_options(options)
|
||||
{
|
||||
uv_mutex_init(&m_mutex);
|
||||
|
||||
m_self = this;
|
||||
|
||||
std::string clientId;
|
||||
|
@ -75,10 +82,12 @@ void CCClient::updateHashrate(const Hashrate *hashrate)
|
|||
{
|
||||
uv_mutex_lock(&m_mutex);
|
||||
|
||||
m_self->m_clientStatus.setHashrateShort(hashrate->calc(Hashrate::ShortInterval));
|
||||
m_self->m_clientStatus.setHashrateMedium(hashrate->calc(Hashrate::MediumInterval));
|
||||
m_self->m_clientStatus.setHashrateLong(hashrate->calc(Hashrate::LargeInterval));
|
||||
m_self->m_clientStatus.setHashrateHighest(hashrate->highest());
|
||||
if (m_self) {
|
||||
m_self->m_clientStatus.setHashrateShort(hashrate->calc(Hashrate::ShortInterval));
|
||||
m_self->m_clientStatus.setHashrateMedium(hashrate->calc(Hashrate::MediumInterval));
|
||||
m_self->m_clientStatus.setHashrateLong(hashrate->calc(Hashrate::LargeInterval));
|
||||
m_self->m_clientStatus.setHashrateHighest(hashrate->highest());
|
||||
}
|
||||
|
||||
uv_mutex_unlock(&m_mutex);
|
||||
}
|
||||
|
@ -88,13 +97,14 @@ void CCClient::updateNetworkState(const NetworkState &network)
|
|||
{
|
||||
uv_mutex_lock(&m_mutex);
|
||||
|
||||
m_self->m_clientStatus.setCurrentStatus(Workers::isEnabled() ? ClientStatus::RUNNING : ClientStatus::PAUSED);
|
||||
m_self->m_clientStatus.setCurrentPool(network.pool);
|
||||
m_self->m_clientStatus.setSharesGood(network.accepted);
|
||||
m_self->m_clientStatus.setSharesTotal(network.accepted + network.rejected);
|
||||
m_self->m_clientStatus.setHashesTotal(network.total);
|
||||
m_self->m_clientStatus.setAvgTime(network.avgTime());
|
||||
|
||||
if (m_self) {
|
||||
m_self->m_clientStatus.setCurrentStatus(Workers::isEnabled() ? ClientStatus::RUNNING : ClientStatus::PAUSED);
|
||||
m_self->m_clientStatus.setCurrentPool(network.pool);
|
||||
m_self->m_clientStatus.setSharesGood(network.accepted);
|
||||
m_self->m_clientStatus.setSharesTotal(network.accepted + network.rejected);
|
||||
m_self->m_clientStatus.setHashesTotal(network.total);
|
||||
m_self->m_clientStatus.setAvgTime(network.avgTime());
|
||||
}
|
||||
uv_mutex_unlock(&m_mutex);
|
||||
}
|
||||
|
||||
|
@ -210,7 +220,9 @@ CURLcode CCClient::performCurl(const std::string& requestUrl, const std::string&
|
|||
|
||||
void CCClient::onReport(uv_timer_t *handle)
|
||||
{
|
||||
m_self->publishClientStatusReport();
|
||||
if (m_self) {
|
||||
m_self->publishClientStatusReport();
|
||||
}
|
||||
}
|
||||
|
||||
int CCClient::onResponse(char* data, size_t size, size_t nmemb, std::string* responseBuffer)
|
||||
|
@ -224,4 +236,3 @@ int CCClient::onResponse(char* data, size_t size, size_t nmemb, std::string* res
|
|||
|
||||
return result;
|
||||
}
|
||||
|
||||
|
|
|
@ -25,6 +25,7 @@
|
|||
#ifndef __CC_CLIENT_H__
|
||||
#define __CC_CLIENT_H__
|
||||
|
||||
#ifndef XMRIG_NO_CC
|
||||
|
||||
#include <uv.h>
|
||||
#include <curl/curl.h>
|
||||
|
@ -68,4 +69,5 @@ private:
|
|||
|
||||
};
|
||||
|
||||
#endif
|
||||
#endif /* __CC_CLIENT_H__ */
|
||||
|
|
|
@ -26,7 +26,6 @@
|
|||
#define __CONTROL_COMMAND_H__
|
||||
|
||||
#include <string>
|
||||
#include <vector>
|
||||
#include "rapidjson/document.h"
|
||||
|
||||
class ControlCommand
|
||||
|
|
|
@ -24,12 +24,19 @@
|
|||
|
||||
#include <stdlib.h>
|
||||
#include <string>
|
||||
#include <regex>
|
||||
|
||||
|
||||
#ifdef WIN32
|
||||
#define WIN32_LEAN_AND_MEAN /* avoid including junk */
|
||||
#include <windows.h>
|
||||
#include <signal.h>
|
||||
#endif
|
||||
int main(int argc, char **argv) {
|
||||
|
||||
std::string ownPath(argv[0]);
|
||||
std::string xmrigMinerPath = std::regex_replace(ownPath, std::regex(program_invocation_short_name), "xmrigMiner");
|
||||
std::string xmrigDaemon("xmrigDaemon");
|
||||
std::string xmrigMiner("xmrigMiner");
|
||||
|
||||
std::string xmrigMinerPath = ownPath.replace(ownPath.rfind(xmrigDaemon),xmrigDaemon.size(), xmrigMiner);
|
||||
|
||||
for (int i=1; i < argc; i++){
|
||||
xmrigMinerPath += " ";
|
||||
|
@ -40,7 +47,9 @@ int main(int argc, char **argv) {
|
|||
|
||||
int status = 0;
|
||||
|
||||
do {
|
||||
//do {
|
||||
status = system(xmrigMinerPath.c_str());
|
||||
} while (WEXITSTATUS(status) == ERESTART);
|
||||
|
||||
printf("Status: %d", status);
|
||||
//} while (WEXITSTATUS(status) == EINTR);
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue