Skip to content

Commit cf72cc9

Browse files
committed
Merge branch 'dev'
2 parents 80d8728 + 175f5be commit cf72cc9

File tree

3 files changed

+38
-11
lines changed

3 files changed

+38
-11
lines changed

src/common/net/Client.cpp

+30-5
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,8 @@ static const char *states[] = {
6666
"host-lookup",
6767
"connecting",
6868
"connected",
69-
"closing"
69+
"closing",
70+
"reconnecting"
7071
};
7172
#endif
7273

@@ -173,10 +174,16 @@ void xmrig::Client::tick(uint64_t now)
173174
else if (m_keepAlive && now > m_keepAlive) {
174175
ping();
175176
}
177+
178+
return;
179+
}
180+
181+
if (m_state == ReconnectingState && m_expire && now > m_expire) {
182+
return connect();
176183
}
177184

178-
if (m_expire && now > m_expire && m_state == ConnectingState) {
179-
connect();
185+
if (m_state == ConnectingState && m_expire && now > m_expire) {
186+
return reconnect();
180187
}
181188
}
182189

@@ -479,7 +486,6 @@ int xmrig::Client::resolve(const char *host)
479486
{
480487
setState(HostLookupState);
481488

482-
m_expire = 0;
483489
m_recvBufPos = 0;
484490

485491
if (m_failures == -1) {
@@ -815,6 +821,8 @@ void xmrig::Client::parseResponse(int64_t id, const rapidjson::Value &result, co
815821
void xmrig::Client::ping()
816822
{
817823
send(snprintf(m_sendBuf, sizeof(m_sendBuf), "{\"id\":%" PRId64 ",\"jsonrpc\":\"2.0\",\"method\":\"keepalived\",\"params\":{\"id\":\"%s\"}}\n", m_sequence, m_rpcId.data()));
824+
825+
m_keepAlive = 0;
818826
}
819827

820828

@@ -861,7 +869,7 @@ void xmrig::Client::reconnect()
861869
return m_listener->onClose(this, -1);
862870
}
863871

864-
setState(ConnectingState);
872+
setState(ReconnectingState);
865873

866874
m_failures++;
867875
m_listener->onClose(this, (int) m_failures);
@@ -878,6 +886,23 @@ void xmrig::Client::setState(SocketState state)
878886
return;
879887
}
880888

889+
switch (state) {
890+
case HostLookupState:
891+
m_expire = 0;
892+
break;
893+
894+
case ConnectingState:
895+
m_expire = uv_now(uv_default_loop()) + kConnectTimeout;
896+
break;
897+
898+
case ReconnectingState:
899+
m_expire = uv_now(uv_default_loop()) + m_retryPause;
900+
break;
901+
902+
default:
903+
break;
904+
}
905+
881906
m_state = state;
882907
}
883908

src/common/net/Client.h

+6-4
Original file line numberDiff line numberDiff line change
@@ -58,15 +58,17 @@ class Client
5858
HostLookupState,
5959
ConnectingState,
6060
ConnectedState,
61-
ClosingState
61+
ClosingState,
62+
ReconnectingState
6263
};
6364

64-
constexpr static int kResponseTimeout = 20 * 1000;
65+
constexpr static uint64_t kConnectTimeout = 20 * 1000;
66+
constexpr static uint64_t kResponseTimeout = 20 * 1000;
6567

6668
# ifndef XMRIG_NO_TLS
67-
constexpr static int kInputBufferSize = 1024 * 16;
69+
constexpr static size_t kInputBufferSize = 1024 * 16;
6870
# else
69-
constexpr static int kInputBufferSize = 1024 * 2;
71+
constexpr static size_t kInputBufferSize = 1024 * 2;
7072
# endif
7173

7274
Client(int id, const char *agent, IClientListener *listener);

src/version.h

+2-2
Original file line numberDiff line numberDiff line change
@@ -28,15 +28,15 @@
2828
#define APP_ID "xmrig-amd"
2929
#define APP_NAME "XMRig-AMD"
3030
#define APP_DESC "XMRig OpenCL miner"
31-
#define APP_VERSION "2.14.5"
31+
#define APP_VERSION "2.14.6-dev"
3232
#define APP_DOMAIN "xmrig.com"
3333
#define APP_SITE "www.xmrig.com"
3434
#define APP_COPYRIGHT "Copyright (C) 2016-2019 xmrig.com"
3535
#define APP_KIND "amd"
3636

3737
#define APP_VER_MAJOR 2
3838
#define APP_VER_MINOR 14
39-
#define APP_VER_PATCH 5
39+
#define APP_VER_PATCH 6
4040

4141
#ifdef _MSC_VER
4242
# if (_MSC_VER >= 1920)

0 commit comments

Comments
 (0)