mirror of
https://github.com/xmrig/xmrig.git
synced 2025-12-25 13:42:54 -05:00
Compare commits
5 Commits
54caaa9227
...
cddb2e7c9f
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
cddb2e7c9f | ||
|
|
33315ba2ef | ||
|
|
2c9c40d623 | ||
|
|
daa6328418 | ||
|
|
6c8098378a |
@@ -32,6 +32,7 @@ option(WITH_VAES "Enable VAES instructions for Cryptonight" ON)
|
|||||||
option(WITH_BENCHMARK "Enable builtin RandomX benchmark and stress test" ON)
|
option(WITH_BENCHMARK "Enable builtin RandomX benchmark and stress test" ON)
|
||||||
option(WITH_SECURE_JIT "Enable secure access to JIT memory" OFF)
|
option(WITH_SECURE_JIT "Enable secure access to JIT memory" OFF)
|
||||||
option(WITH_DMI "Enable DMI/SMBIOS reader" ON)
|
option(WITH_DMI "Enable DMI/SMBIOS reader" ON)
|
||||||
|
option(WITH_AUTO_HUGEPAGE "Enable Automatic setting of nr_hugepages (Linux Only)" ON)
|
||||||
|
|
||||||
option(BUILD_STATIC "Build static binary" OFF)
|
option(BUILD_STATIC "Build static binary" OFF)
|
||||||
option(ARM_V8 "Force ARMv8 (64 bit) architecture, use with caution if automatic detection fails, but you sure it may work" OFF)
|
option(ARM_V8 "Force ARMv8 (64 bit) architecture, use with caution if automatic detection fails, but you sure it may work" OFF)
|
||||||
@@ -181,6 +182,10 @@ else()
|
|||||||
if (XMRIG_OS_ANDROID)
|
if (XMRIG_OS_ANDROID)
|
||||||
set(EXTRA_LIBS pthread rt dl log)
|
set(EXTRA_LIBS pthread rt dl log)
|
||||||
elseif (XMRIG_OS_LINUX)
|
elseif (XMRIG_OS_LINUX)
|
||||||
|
if (WITH_AUTO_HUGEPAGE)
|
||||||
|
add_definitions(/DXMRIG_FEATURE_AUTO_HUGEPAGE)
|
||||||
|
endif()
|
||||||
|
|
||||||
list(APPEND SOURCES_OS
|
list(APPEND SOURCES_OS
|
||||||
src/crypto/common/LinuxMemory.h
|
src/crypto/common/LinuxMemory.h
|
||||||
src/crypto/common/LinuxMemory.cpp
|
src/crypto/common/LinuxMemory.cpp
|
||||||
|
|||||||
@@ -39,6 +39,7 @@
|
|||||||
|
|
||||||
|
|
||||||
#include <thread>
|
#include <thread>
|
||||||
|
#include <iostream>
|
||||||
|
|
||||||
|
|
||||||
namespace xmrig {
|
namespace xmrig {
|
||||||
@@ -80,7 +81,8 @@ static rapidjson::Value getResources(rapidjson::Document &doc)
|
|||||||
|
|
||||||
xmrig::Api::Api(Base *base) :
|
xmrig::Api::Api(Base *base) :
|
||||||
m_base(base),
|
m_base(base),
|
||||||
m_timestamp(Chrono::currentMSecsSinceEpoch())
|
m_timestamp(Chrono::currentMSecsSinceEpoch()),
|
||||||
|
m_httpd(nullptr)
|
||||||
{
|
{
|
||||||
base->addListener(this);
|
base->addListener(this);
|
||||||
|
|
||||||
@@ -91,7 +93,11 @@ xmrig::Api::Api(Base *base) :
|
|||||||
xmrig::Api::~Api()
|
xmrig::Api::~Api()
|
||||||
{
|
{
|
||||||
# ifdef XMRIG_FEATURE_HTTP
|
# ifdef XMRIG_FEATURE_HTTP
|
||||||
delete m_httpd;
|
if (m_httpd) {
|
||||||
|
m_httpd->stop();
|
||||||
|
delete m_httpd;
|
||||||
|
m_httpd = nullptr; // Ensure the pointer is set to nullptr after deletion
|
||||||
|
}
|
||||||
# endif
|
# endif
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -109,8 +115,14 @@ void xmrig::Api::start()
|
|||||||
genWorkerId(m_base->config()->apiWorkerId());
|
genWorkerId(m_base->config()->apiWorkerId());
|
||||||
|
|
||||||
# ifdef XMRIG_FEATURE_HTTP
|
# ifdef XMRIG_FEATURE_HTTP
|
||||||
m_httpd = new Httpd(m_base);
|
if (!m_httpd) {
|
||||||
m_httpd->start();
|
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;
|
||||||
|
}
|
||||||
|
}
|
||||||
# endif
|
# endif
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -118,7 +130,9 @@ void xmrig::Api::start()
|
|||||||
void xmrig::Api::stop()
|
void xmrig::Api::stop()
|
||||||
{
|
{
|
||||||
# ifdef XMRIG_FEATURE_HTTP
|
# ifdef XMRIG_FEATURE_HTTP
|
||||||
m_httpd->stop();
|
if (m_httpd) {
|
||||||
|
m_httpd->stop();
|
||||||
|
}
|
||||||
# endif
|
# endif
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -126,13 +140,15 @@ void xmrig::Api::stop()
|
|||||||
void xmrig::Api::tick()
|
void xmrig::Api::tick()
|
||||||
{
|
{
|
||||||
# ifdef XMRIG_FEATURE_HTTP
|
# ifdef XMRIG_FEATURE_HTTP
|
||||||
if (m_httpd->isBound() || !m_base->config()->http().isEnabled()) {
|
if (!m_httpd || !m_base->config()->http().isEnabled() || m_httpd->isBound()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (++m_ticks % 10 == 0) {
|
if (++m_ticks % 10 == 0) {
|
||||||
m_ticks = 0;
|
m_ticks = 0;
|
||||||
m_httpd->start();
|
if (m_httpd) {
|
||||||
|
m_httpd->start();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
# endif
|
# endif
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -60,7 +60,11 @@ bool xmrig::LinuxMemory::reserve(size_t size, uint32_t node, size_t hugePageSize
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# ifdef XMRIG_FEATURE_AUTO_HUGEPAGE
|
||||||
return write_nr_hugepages(node, hugePageSize, std::max<size_t>(nr_hugepages(node, hugePageSize), 0) + (required - available));
|
return write_nr_hugepages(node, hugePageSize, std::max<size_t>(nr_hugepages(node, hugePageSize), 0) + (required - available));
|
||||||
|
# else
|
||||||
|
return false;
|
||||||
|
# endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user