mirror of
https://github.com/GOSTSec/sgminer
synced 2025-02-02 10:04:33 +00:00
Suspend stratum connections to backup pools when there is no requirement to potentially grab work from them.
This commit is contained in:
parent
16637ac91e
commit
fc5d3a0eaf
38
cgminer.c
38
cgminer.c
@ -4676,6 +4676,28 @@ static void clear_stratum_shares(struct pool *pool)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* We only need to maintain a secondary pool connection when we need the
|
||||||
|
* capacity to get work from the backup pools while still on the primary */
|
||||||
|
static bool cnx_needed(struct pool *pool)
|
||||||
|
{
|
||||||
|
struct pool *cp;
|
||||||
|
|
||||||
|
if (pool_strategy == POOL_BALANCE)
|
||||||
|
return true;
|
||||||
|
if (pool_strategy == POOL_LOADBALANCE)
|
||||||
|
return true;
|
||||||
|
if (opt_fail_only)
|
||||||
|
return true;
|
||||||
|
cp = current_pool();
|
||||||
|
if (cp == pool)
|
||||||
|
return true;
|
||||||
|
if (!cp->has_gbt && !cp->has_stratum)
|
||||||
|
return true;
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
static void wait_lpcurrent(struct pool *pool);
|
||||||
|
|
||||||
/* One stratum thread per pool that has stratum waits on the socket checking
|
/* One stratum thread per pool that has stratum waits on the socket checking
|
||||||
* for new messages and for the integrity of the socket connection. We reset
|
* for new messages and for the integrity of the socket connection. We reset
|
||||||
* the connection based on the integrity of the receive side only as the send
|
* the connection based on the integrity of the receive side only as the send
|
||||||
@ -4696,6 +4718,22 @@ static void *stratum_thread(void *userdata)
|
|||||||
if (unlikely(pool->removed))
|
if (unlikely(pool->removed))
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
/* Check to see whether we need to maintain this connection
|
||||||
|
* indefinitely or just bring it up when we switch to this
|
||||||
|
* pool */
|
||||||
|
if (!cnx_needed(pool)) {
|
||||||
|
suspend_stratum(pool);
|
||||||
|
wait_lpcurrent(pool);
|
||||||
|
if (!initiate_stratum(pool) || !auth_stratum(pool)) {
|
||||||
|
pool_died(pool);
|
||||||
|
while (!initiate_stratum(pool) || !auth_stratum(pool)) {
|
||||||
|
if (pool->removed)
|
||||||
|
goto out;
|
||||||
|
sleep(30);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
FD_ZERO(&rd);
|
FD_ZERO(&rd);
|
||||||
FD_SET(pool->sock, &rd);
|
FD_SET(pool->sock, &rd);
|
||||||
timeout.tv_sec = 90;
|
timeout.tv_sec = 90;
|
||||||
|
8
util.c
8
util.c
@ -1435,6 +1435,14 @@ out:
|
|||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void suspend_stratum(struct pool *pool)
|
||||||
|
{
|
||||||
|
applog(LOG_INFO, "Closing socket for stratum pool %d", pool->pool_no);
|
||||||
|
mutex_lock(&pool->stratum_lock);
|
||||||
|
pool->stratum_active = false;
|
||||||
|
mutex_unlock(&pool->stratum_lock);
|
||||||
|
CLOSESOCKET(pool->sock);
|
||||||
|
}
|
||||||
|
|
||||||
void dev_error(struct cgpu_info *dev, enum dev_reason reason)
|
void dev_error(struct cgpu_info *dev, enum dev_reason reason)
|
||||||
{
|
{
|
||||||
|
1
util.h
1
util.h
@ -51,6 +51,7 @@ bool parse_method(struct pool *pool, char *s);
|
|||||||
bool extract_sockaddr(struct pool *pool, char *url);
|
bool extract_sockaddr(struct pool *pool, char *url);
|
||||||
bool auth_stratum(struct pool *pool);
|
bool auth_stratum(struct pool *pool);
|
||||||
bool initiate_stratum(struct pool *pool);
|
bool initiate_stratum(struct pool *pool);
|
||||||
|
void suspend_stratum(struct pool *pool);
|
||||||
void dev_error(struct cgpu_info *dev, enum dev_reason reason);
|
void dev_error(struct cgpu_info *dev, enum dev_reason reason);
|
||||||
void *realloc_strcat(char *ptr, char *s);
|
void *realloc_strcat(char *ptr, char *s);
|
||||||
void RenameThread(const char* name);
|
void RenameThread(const char* name);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user