mirror of
https://github.com/xmrig/xmrig.git
synced 2024-12-23 12:09:22 +00:00
#1421 Added limit for maximum send buffer size.
This commit is contained in:
parent
17f82280d0
commit
a5089638ea
2 changed files with 11 additions and 8 deletions
|
@ -159,6 +159,13 @@ int64_t xmrig::Client::send(const rapidjson::Value &obj)
|
||||||
obj.Accept(writer);
|
obj.Accept(writer);
|
||||||
|
|
||||||
const size_t size = buffer.GetSize();
|
const size_t size = buffer.GetSize();
|
||||||
|
if (size > kMaxSendBufferSize) {
|
||||||
|
LOG_ERR("[%s] send failed: \"max send buffer size exceeded: %zu\"", url(), size);
|
||||||
|
close();
|
||||||
|
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
if (size > (m_sendBuf.size() - 2)) {
|
if (size > (m_sendBuf.size() - 2)) {
|
||||||
m_sendBuf.resize(((size + 1) / 1024 + 1) * 1024);
|
m_sendBuf.resize(((size + 1) / 1024 + 1) * 1024);
|
||||||
}
|
}
|
||||||
|
|
|
@ -60,14 +60,10 @@ class Client : public BaseClient, public IDnsListener, public ILineListener
|
||||||
public:
|
public:
|
||||||
XMRIG_DISABLE_COPY_MOVE_DEFAULT(Client)
|
XMRIG_DISABLE_COPY_MOVE_DEFAULT(Client)
|
||||||
|
|
||||||
constexpr static uint64_t kConnectTimeout = 20 * 1000;
|
constexpr static uint64_t kConnectTimeout = 20 * 1000;
|
||||||
constexpr static uint64_t kResponseTimeout = 20 * 1000;
|
constexpr static uint64_t kResponseTimeout = 20 * 1000;
|
||||||
|
constexpr static size_t kInputBufferSize = 1024 * 16;
|
||||||
# ifdef XMRIG_FEATURE_TLS
|
constexpr static size_t kMaxSendBufferSize = 1024 * 16;
|
||||||
constexpr static size_t kInputBufferSize = 1024 * 16;
|
|
||||||
# else
|
|
||||||
constexpr static size_t kInputBufferSize = 1024 * 2;
|
|
||||||
# endif
|
|
||||||
|
|
||||||
Client(int id, const char *agent, IClientListener *listener);
|
Client(int id, const char *agent, IClientListener *listener);
|
||||||
~Client() override;
|
~Client() override;
|
||||||
|
|
Loading…
Reference in a new issue