mirror of
https://github.com/xmrig/xmrig-proxy.git
synced 2026-02-09 02:59:17 +08:00
Fixed mishandled timeouts.
This commit is contained in:
@@ -58,7 +58,7 @@ namespace xmrig {
|
||||
static int64_t nextId = 0;
|
||||
char Miner::m_sendBuf[16384] = { 0 };
|
||||
Storage<Miner> Miner::m_storage;
|
||||
}
|
||||
} // namespace xmrig
|
||||
|
||||
|
||||
xmrig::Miner::Miner(const TlsContext *ctx, uint16_t port, bool strictTls) :
|
||||
@@ -67,7 +67,7 @@ xmrig::Miner::Miner(const TlsContext *ctx, uint16_t port, bool strictTls) :
|
||||
m_tlsCtx(ctx),
|
||||
m_id(++nextId),
|
||||
m_localPort(port),
|
||||
m_expire(Chrono::currentMSecsSinceEpoch() + kLoginTimeout),
|
||||
m_expire(Chrono::steadyMSecs() + kLoginTimeout),
|
||||
m_timestamp(Chrono::currentMSecsSinceEpoch())
|
||||
{
|
||||
m_reader.setListener(this);
|
||||
@@ -215,7 +215,7 @@ bool xmrig::Miner::parseRequest(int64_t id, const char *method, const rapidjson:
|
||||
algorithms.reserve(value.Size());
|
||||
|
||||
for (const auto &i : value.GetArray()) {
|
||||
Algorithm algo(i.GetString());
|
||||
const Algorithm algo(i.GetString());
|
||||
if (!algo.isValid()) {
|
||||
continue;
|
||||
}
|
||||
@@ -324,7 +324,7 @@ bool xmrig::Miner::send(BIO *bio)
|
||||
|
||||
void xmrig::Miner::heartbeat()
|
||||
{
|
||||
m_expire = Chrono::currentMSecsSinceEpoch() + kSocketTimeout;
|
||||
m_expire = Chrono::steadyMSecs() + kSocketTimeout;
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -5,8 +5,8 @@
|
||||
* Copyright 2014-2016 Wolf9466 <https://github.com/OhGodAPet>
|
||||
* Copyright 2016 Jay D Dee <jayddee246@gmail.com>
|
||||
* Copyright 2017-2018 XMR-Stak <https://github.com/fireice-uk>, <https://github.com/psychocrypt>
|
||||
* Copyright 2018-2021 SChernykh <https://github.com/SChernykh>
|
||||
* Copyright 2016-2021 XMRig <https://github.com/xmrig>, <support@xmrig.com>
|
||||
* Copyright 2018-2025 SChernykh <https://github.com/SChernykh>
|
||||
* Copyright 2016-2025 XMRig <https://github.com/xmrig>, <support@xmrig.com>
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
@@ -25,12 +25,10 @@
|
||||
#ifndef XMRIG_MINER_H
|
||||
#define XMRIG_MINER_H
|
||||
|
||||
|
||||
#include <algorithm>
|
||||
#include <bitset>
|
||||
#include <uv.h>
|
||||
|
||||
|
||||
#include "3rdparty/rapidjson/fwd.h"
|
||||
#include "base/kernel/interfaces/ILineListener.h"
|
||||
#include "base/net/tools/LineReader.h"
|
||||
@@ -147,7 +145,7 @@ private:
|
||||
String m_rigId;
|
||||
String m_user;
|
||||
String m_signatureData;
|
||||
uint8_t m_viewTag;
|
||||
uint8_t m_viewTag = 0;
|
||||
Tls *m_tls = nullptr;
|
||||
uint16_t m_localPort;
|
||||
uint64_t m_customDiff = 0;
|
||||
@@ -166,6 +164,6 @@ private:
|
||||
};
|
||||
|
||||
|
||||
} /* namespace xmrig */
|
||||
} // namespace xmrig
|
||||
|
||||
#endif /* XMRIG_MINER_H */
|
||||
#endif // XMRIG_MINER_H
|
||||
|
||||
@@ -5,8 +5,8 @@
|
||||
* Copyright 2014-2016 Wolf9466 <https://github.com/OhGodAPet>
|
||||
* Copyright 2016 Jay D Dee <jayddee246@gmail.com>
|
||||
* Copyright 2017-2018 XMR-Stak <https://github.com/fireice-uk>, <https://github.com/psychocrypt>
|
||||
* Copyright 2018-2019 SChernykh <https://github.com/SChernykh>
|
||||
* Copyright 2016-2019 XMRig <https://github.com/xmrig>, <support@xmrig.com>
|
||||
* Copyright 2018-2025 SChernykh <https://github.com/SChernykh>
|
||||
* Copyright 2016-2025 XMRig <https://github.com/xmrig>, <support@xmrig.com>
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
@@ -25,8 +25,7 @@
|
||||
|
||||
#include <vector>
|
||||
|
||||
|
||||
#include "base/io/log/Log.h"
|
||||
#include "base/tools/Chrono.h"
|
||||
#include "base/tools/Handle.h"
|
||||
#include "proxy/events/CloseEvent.h"
|
||||
#include "proxy/events/ConnectionEvent.h"
|
||||
@@ -34,9 +33,9 @@
|
||||
#include "proxy/Miners.h"
|
||||
|
||||
|
||||
xmrig::Miners::Miners()
|
||||
xmrig::Miners::Miners() :
|
||||
m_timer(new uv_timer_t)
|
||||
{
|
||||
m_timer = new uv_timer_t;
|
||||
m_timer->data = this;
|
||||
uv_timer_init(uv_default_loop(), m_timer);
|
||||
uv_timer_start(m_timer, [](uv_timer_t *handle) { static_cast<Miners*>(handle->data)->tick(); }, kTickInterval, kTickInterval);
|
||||
@@ -101,7 +100,7 @@ void xmrig::Miners::remove(Miner *miner)
|
||||
|
||||
void xmrig::Miners::tick()
|
||||
{
|
||||
const uint64_t now = uv_now(uv_default_loop());
|
||||
const uint64_t now = Chrono::steadyMSecs();
|
||||
std::vector<Miner*> expired;
|
||||
|
||||
for (auto const &kv : m_miners) {
|
||||
@@ -114,7 +113,7 @@ void xmrig::Miners::tick()
|
||||
return;
|
||||
}
|
||||
|
||||
for (auto miner : expired) {
|
||||
for (auto *miner : expired) {
|
||||
miner->close();
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user