From b8762ed428cfac4903f880b260000b274d2c1bd4 Mon Sep 17 00:00:00 2001 From: XMRig Date: Fri, 6 Dec 2019 10:56:43 +0700 Subject: [PATCH] #1306 Added some network workarounds. --- src/base/net/stratum/Client.cpp | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/src/base/net/stratum/Client.cpp b/src/base/net/stratum/Client.cpp index 9729f3fb..f9c56e05 100644 --- a/src/base/net/stratum/Client.cpp +++ b/src/base/net/stratum/Client.cpp @@ -338,6 +338,10 @@ bool xmrig::Client::isCriticalError(const char *message) return true; } + if (strncasecmp(message, "Invalid job id", 14) == 0) { + return true; + } + return false; } @@ -558,7 +562,7 @@ void xmrig::Client::connect(sockaddr *addr) { setState(ConnectingState); - uv_connect_t *req = new uv_connect_t; + auto req = new uv_connect_t; req->data = m_storage.ptr(m_key); m_socket = new uv_tcp_t; @@ -799,7 +803,7 @@ void xmrig::Client::ping() void xmrig::Client::read(ssize_t nread) { - const size_t size = static_cast(nread); + const auto size = static_cast(nread); if (nread > 0 && size > m_recvBuf.available()) { nread = UV_ENOBUFS; @@ -859,7 +863,7 @@ void xmrig::Client::reconnect() void xmrig::Client::setState(SocketState state) { - LOG_DEBUG("[%s] state: \"%s\"", url(), states[state]); + LOG_DEBUG("[%s] state: \"%s\" -> \"%s\"", url(), states[m_state], states[state]); if (m_state == state) { return; @@ -956,6 +960,12 @@ void xmrig::Client::onConnect(uv_connect_t *req, int status) return; } + if (client->state() == ConnectedState) { + LOG_ERR("[%s] already connected"); + + return; + } + client->m_stream = static_cast(req->handle); client->m_stream->data = req->data; client->setState(ConnectedState);