Skip to content

Commit

Permalink
Fixed multiple network bugs
Browse files Browse the repository at this point in the history
  • Loading branch information
xmrig committed Aug 31, 2019
1 parent 59f8d83 commit a047dc3
Show file tree
Hide file tree
Showing 4 changed files with 41 additions and 11 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
# v2.14.5
- [#1138](https://github.com/xmrig/xmrig/issues/1138) Fixed multiple network bugs.

# v2.14.4
- [#260](https://github.com/xmrig/xmrig-nvidia/issues/260) Fixed `cn/r` algorithm slowdown with CUDA 10.1+.
- [#268](https://github.com/xmrig/xmrig-nvidia/pull/268) Added support for NVIDIA Jetson.
Expand Down
35 changes: 30 additions & 5 deletions src/common/net/Client.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,8 @@ static const char *states[] = {
"host-lookup",
"connecting",
"connected",
"closing"
"closing",
"reconnecting"
};
#endif

Expand Down Expand Up @@ -173,10 +174,16 @@ void xmrig::Client::tick(uint64_t now)
else if (m_keepAlive && now > m_keepAlive) {
ping();
}

return;
}

if (m_state == ReconnectingState && m_expire && now > m_expire) {
return connect();
}

if (m_expire && now > m_expire && m_state == ConnectingState) {
connect();
if (m_state == ConnectingState && m_expire && now > m_expire) {
return reconnect();
}
}

Expand Down Expand Up @@ -479,7 +486,6 @@ int xmrig::Client::resolve(const char *host)
{
setState(HostLookupState);

m_expire = 0;
m_recvBufPos = 0;

if (m_failures == -1) {
Expand Down Expand Up @@ -815,6 +821,8 @@ void xmrig::Client::parseResponse(int64_t id, const rapidjson::Value &result, co
void xmrig::Client::ping()
{
send(snprintf(m_sendBuf, sizeof(m_sendBuf), "{\"id\":%" PRId64 ",\"jsonrpc\":\"2.0\",\"method\":\"keepalived\",\"params\":{\"id\":\"%s\"}}\n", m_sequence, m_rpcId.data()));

m_keepAlive = 0;
}


Expand Down Expand Up @@ -861,7 +869,7 @@ void xmrig::Client::reconnect()
return m_listener->onClose(this, -1);
}

setState(ConnectingState);
setState(ReconnectingState);

m_failures++;
m_listener->onClose(this, (int) m_failures);
Expand All @@ -878,6 +886,23 @@ void xmrig::Client::setState(SocketState state)
return;
}

switch (state) {
case HostLookupState:
m_expire = 0;
break;

case ConnectingState:
m_expire = uv_now(uv_default_loop()) + kConnectTimeout;
break;

case ReconnectingState:
m_expire = uv_now(uv_default_loop()) + m_retryPause;
break;

default:
break;
}

m_state = state;
}

Expand Down
10 changes: 6 additions & 4 deletions src/common/net/Client.h
Original file line number Diff line number Diff line change
Expand Up @@ -58,15 +58,17 @@ class Client
HostLookupState,
ConnectingState,
ConnectedState,
ClosingState
ClosingState,
ReconnectingState
};

constexpr static int kResponseTimeout = 20 * 1000;
constexpr static uint64_t kConnectTimeout = 20 * 1000;
constexpr static uint64_t kResponseTimeout = 20 * 1000;

# ifndef XMRIG_NO_TLS
constexpr static int kInputBufferSize = 1024 * 16;
constexpr static size_t kInputBufferSize = 1024 * 16;
# else
constexpr static int kInputBufferSize = 1024 * 2;
constexpr static size_t kInputBufferSize = 1024 * 2;
# endif

Client(int id, const char *agent, IClientListener *listener);
Expand Down
4 changes: 2 additions & 2 deletions src/version.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,15 +28,15 @@
#define APP_ID "xmrig-nvidia"
#define APP_NAME "XMRig-NVIDIA"
#define APP_DESC "XMRig CUDA miner"
#define APP_VERSION "2.14.4"
#define APP_VERSION "2.14.5"
#define APP_DOMAIN "xmrig.com"
#define APP_SITE "www.xmrig.com"
#define APP_COPYRIGHT "Copyright (C) 2016-2019 xmrig.com"
#define APP_KIND "nvidia"

#define APP_VER_MAJOR 2
#define APP_VER_MINOR 14
#define APP_VER_PATCH 4
#define APP_VER_PATCH 5

#ifdef _MSC_VER
# if (_MSC_VER >= 1920)
Expand Down

0 comments on commit a047dc3

Please sign in to comment.