Merge from xmrig-2.8.1

This commit is contained in:
MoneroOcean 2018-10-09 10:53:12 +02:00
commit e314fa8ec9
15 changed files with 887 additions and 34 deletions

View file

@ -71,7 +71,7 @@ static inline void cpuid(int level, int output[4]) {
static inline void cpu_brand_string(char* s) {
int cpu_info[4] = { 0 };
int32_t cpu_info[4] = { 0 };
cpuid(VENDOR_ID, cpu_info);
if (cpu_info[EAX_Reg] >= 4) {
@ -86,7 +86,7 @@ static inline void cpu_brand_string(char* s) {
static inline bool has_aes_ni()
{
int cpu_info[4] = { 0 };
int32_t cpu_info[4] = { 0 };
cpuid(PROCESSOR_INFO, cpu_info);
return (cpu_info[ECX_Reg] & bit_AES) != 0;
@ -94,11 +94,32 @@ static inline bool has_aes_ni()
xmrig::BasicCpuInfo::BasicCpuInfo() :
m_assembly(ASM_NONE),
m_aes(has_aes_ni()),
m_brand(),
m_threads(std::thread::hardware_concurrency())
{
cpu_brand_string(m_brand);
# ifndef XMRIG_NO_ASM
if (hasAES()) {
char vendor[13] = { 0 };
int32_t data[4] = { 0 };
cpuid(0, data);
memcpy(vendor + 0, &data[1], 4);
memcpy(vendor + 4, &data[3], 4);
memcpy(vendor + 8, &data[2], 4);
if (memcmp(vendor, "GenuineIntel", 12) == 0) {
m_assembly = ASM_INTEL;
}
else if (memcmp(vendor, "AuthenticAMD", 12) == 0) {
m_assembly = ASM_RYZEN;
}
}
# endif
}

View file

@ -7,7 +7,6 @@
* Copyright 2017-2018 XMR-Stak <https://github.com/fireice-uk>, <https://github.com/psychocrypt>
* Copyright 2016-2018 XMRig <https://github.com/xmrig>, <support@xmrig.com>
*
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
@ -40,7 +39,7 @@ public:
protected:
size_t optimalThreadsCount(size_t memSize, int maxCpuUsage) const override;
inline Assembly assembly() const override { return ASM_NONE; }
inline Assembly assembly() const override { return m_assembly; }
inline bool hasAES() const override { return m_aes; }
inline bool isSupported() const override { return true; }
inline const char *brand() const override { return m_brand; }
@ -58,6 +57,7 @@ protected:
# endif
private:
Assembly m_assembly;
bool m_aes;
char m_brand[64];
int32_t m_threads;

View file

@ -262,7 +262,11 @@ int64_t Client::submit(const JobResult &result)
bool Client::close()
{
if (m_state == UnconnectedState || m_state == ClosingState || !m_socket) {
if (m_state == ClosingState) {
return m_socket != nullptr;
}
if (m_state == UnconnectedState || m_socket == nullptr) {
return false;
}
@ -433,7 +437,7 @@ bool Client::send(BIO *bio)
bool Client::verifyAlgorithm(const xmrig::Algorithm &algorithm) const
{
# ifdef XMRIG_PROXY_PROJECT
if (m_pool.algorithm().variant() == xmrig::VARIANT_AUTO) {
if (m_pool.algorithm().variant() == xmrig::VARIANT_AUTO || m_id == -1) {
return true;
}
# endif
@ -557,7 +561,6 @@ void Client::connect(sockaddr *addr)
setState(ConnectingState);
reinterpret_cast<sockaddr_in*>(addr)->sin_port = htons(m_pool.port());
delete m_socket;
uv_connect_t *req = new uv_connect_t;
req->data = m_storage.ptr(m_key);
@ -848,13 +851,14 @@ void Client::reconnect()
return;
}
setState(ConnectingState);
m_keepAlive = 0;
if (m_failures == -1) {
return m_listener->onClose(this, -1);
}
setState(ConnectingState);
m_failures++;
m_listener->onClose(this, (int) m_failures);
@ -944,7 +948,7 @@ void Client::onRead(uv_stream_t *stream, ssize_t nread, const uv_buf_t *buf)
}
if (nread < 0) {
if (nread != UV_EOF && !client->isQuiet()) {
if (!client->isQuiet()) {
LOG_ERR("[%s] read error: \"%s\"", client->m_pool.url(), uv_strerror((int) nread));
}