mirror of
https://github.com/xmrig/xmrig.git
synced 2025-12-25 13:42:54 -05:00
Compare commits
1 Commits
cddb2e7c9f
...
54caaa9227
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
54caaa9227 |
@@ -39,7 +39,6 @@
|
||||
|
||||
|
||||
#include <thread>
|
||||
#include <iostream>
|
||||
|
||||
|
||||
namespace xmrig {
|
||||
@@ -81,8 +80,7 @@ static rapidjson::Value getResources(rapidjson::Document &doc)
|
||||
|
||||
xmrig::Api::Api(Base *base) :
|
||||
m_base(base),
|
||||
m_timestamp(Chrono::currentMSecsSinceEpoch()),
|
||||
m_httpd(nullptr)
|
||||
m_timestamp(Chrono::currentMSecsSinceEpoch())
|
||||
{
|
||||
base->addListener(this);
|
||||
|
||||
@@ -93,11 +91,7 @@ xmrig::Api::Api(Base *base) :
|
||||
xmrig::Api::~Api()
|
||||
{
|
||||
# ifdef XMRIG_FEATURE_HTTP
|
||||
if (m_httpd) {
|
||||
m_httpd->stop();
|
||||
delete m_httpd;
|
||||
m_httpd = nullptr; // Ensure the pointer is set to nullptr after deletion
|
||||
}
|
||||
delete m_httpd;
|
||||
# endif
|
||||
}
|
||||
|
||||
@@ -115,14 +109,8 @@ void xmrig::Api::start()
|
||||
genWorkerId(m_base->config()->apiWorkerId());
|
||||
|
||||
# ifdef XMRIG_FEATURE_HTTP
|
||||
if (!m_httpd) {
|
||||
m_httpd = new Httpd(m_base);
|
||||
if (!m_httpd->start()) {
|
||||
std::cerr << "HTTP server failed to start." << std::endl;
|
||||
delete m_httpd; // Properly handle failure to start
|
||||
m_httpd = nullptr;
|
||||
}
|
||||
}
|
||||
m_httpd = new Httpd(m_base);
|
||||
m_httpd->start();
|
||||
# endif
|
||||
}
|
||||
|
||||
@@ -130,9 +118,7 @@ void xmrig::Api::start()
|
||||
void xmrig::Api::stop()
|
||||
{
|
||||
# ifdef XMRIG_FEATURE_HTTP
|
||||
if (m_httpd) {
|
||||
m_httpd->stop();
|
||||
}
|
||||
m_httpd->stop();
|
||||
# endif
|
||||
}
|
||||
|
||||
@@ -140,15 +126,13 @@ void xmrig::Api::stop()
|
||||
void xmrig::Api::tick()
|
||||
{
|
||||
# ifdef XMRIG_FEATURE_HTTP
|
||||
if (!m_httpd || !m_base->config()->http().isEnabled() || m_httpd->isBound()) {
|
||||
if (m_httpd->isBound() || !m_base->config()->http().isEnabled()) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (++m_ticks % 10 == 0) {
|
||||
m_ticks = 0;
|
||||
if (m_httpd) {
|
||||
m_httpd->start();
|
||||
}
|
||||
m_httpd->start();
|
||||
}
|
||||
# endif
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user