#459 Fix issue with xmr.f2pool.com

This commit is contained in:
XMRig 2018-03-17 16:30:41 +07:00
parent 38c39321d0
commit de5016dda8
4 changed files with 32 additions and 10 deletions

View file

@ -65,6 +65,7 @@ Client::Client(int id, const char *agent, IClientListener *listener) :
m_recvBufPos(0), m_recvBufPos(0),
m_state(UnconnectedState), m_state(UnconnectedState),
m_expire(0), m_expire(0),
m_jobs(0),
m_stream(nullptr), m_stream(nullptr),
m_socket(nullptr) m_socket(nullptr)
{ {
@ -245,17 +246,22 @@ bool Client::parseJob(const rapidjson::Value &params, int *code)
job.setVariant(params["variant"].GetInt()); job.setVariant(params["variant"].GetInt());
} }
if (m_job == job) { if (m_job != job) {
if (!m_quiet) { m_jobs++;
LOG_WARN("[%s:%u] duplicate job received, reconnect", m_url.host(), m_url.port()); m_job = std::move(job);
} return true;
}
close(); if (m_jobs == 0) { // https://github.com/xmrig/xmrig/issues/459
return false; return false;
} }
m_job = std::move(job); if (!m_quiet) {
return true; LOG_WARN("[%s:%u] duplicate job received, reconnect", m_url.host(), m_url.port());
}
close();
return false;
} }
@ -272,7 +278,10 @@ bool Client::parseLogin(const rapidjson::Value &result, int *code)
parseExtensions(result["extensions"]); parseExtensions(result["extensions"]);
} }
return parseJob(result["job"], code); const bool rc = parseJob(result["job"], code);
m_jobs = 0;
return rc;
} }
@ -683,7 +692,10 @@ void Client::onResolved(uv_getaddrinfo_t *req, int status, struct addrinfo *res)
{ {
auto client = getClient(req->data); auto client = getClient(req->data);
if (status < 0) { if (status < 0) {
LOG_ERR("[%s:%u] DNS error: \"%s\"", client->m_url.host(), client->m_url.port(), uv_strerror(status)); if (!client->m_quiet) {
LOG_ERR("[%s:%u] DNS error: \"%s\"", client->m_url.host(), client->m_url.port(), uv_strerror(status));
}
return client->reconnect(); return client->reconnect();
} }
@ -704,7 +716,9 @@ void Client::onResolved(uv_getaddrinfo_t *req, int status, struct addrinfo *res)
} }
if (ipv4.empty() && ipv6.empty()) { if (ipv4.empty() && ipv6.empty()) {
LOG_ERR("[%s:%u] DNS error: \"No IPv4 (A) or IPv6 (AAAA) records found\"", client->m_url.host(), client->m_url.port()); if (!client->m_quiet) {
LOG_ERR("[%s:%u] DNS error: \"No IPv4 (A) or IPv6 (AAAA) records found\"", client->m_url.host(), client->m_url.port());
}
uv_freeaddrinfo(res); uv_freeaddrinfo(res);
return client->reconnect(); return client->reconnect();

View file

@ -120,6 +120,7 @@ private:
static int64_t m_sequence; static int64_t m_sequence;
std::map<int64_t, SubmitResult> m_results; std::map<int64_t, SubmitResult> m_results;
uint64_t m_expire; uint64_t m_expire;
uint64_t m_jobs;
Url m_url; Url m_url;
uv_buf_t m_recvBuf; uv_buf_t m_recvBuf;
uv_getaddrinfo_t m_resolver; uv_getaddrinfo_t m_resolver;

View file

@ -210,3 +210,9 @@ bool Job::operator==(const Job &other) const
{ {
return m_id == other.m_id && memcmp(m_blob, other.m_blob, sizeof(m_blob)) == 0; return m_id == other.m_id && memcmp(m_blob, other.m_blob, sizeof(m_blob)) == 0;
} }
bool Job::operator!=(const Job &other) const
{
return m_id != other.m_id || memcmp(m_blob, other.m_blob, sizeof(m_blob)) != 0;
}

View file

@ -69,6 +69,7 @@ public:
static void toHex(const unsigned char* in, unsigned int len, char* out); static void toHex(const unsigned char* in, unsigned int len, char* out);
bool operator==(const Job &other) const; bool operator==(const Job &other) const;
bool operator!=(const Job &other) const;
private: private:
bool m_nicehash; bool m_nicehash;