mirror of
https://github.com/GOSTSec/sgminer
synced 2025-01-09 14:28:12 +00:00
Change stratum strings under stratum_lock in reconnect and free old strings.
Conflicts resolved: util.c
This commit is contained in:
parent
91d36d097a
commit
003b65b7b1
31
util.c
31
util.c
@ -1661,8 +1661,18 @@ static bool parse_diff(struct pool *pool, json_t *val)
|
||||
return true;
|
||||
}
|
||||
|
||||
static void __suspend_stratum(struct pool *pool)
|
||||
{
|
||||
clear_sockbuf(pool);
|
||||
pool->stratum_active = pool->stratum_notify = false;
|
||||
if (pool->sock)
|
||||
CLOSESOCKET(pool->sock);
|
||||
pool->sock = 0;
|
||||
}
|
||||
|
||||
static bool parse_reconnect(struct pool *pool, json_t *val)
|
||||
{
|
||||
char *sockaddr_url, *stratum_port, *tmp;
|
||||
char *url, *port, address[256];
|
||||
|
||||
memset(address, 0, 255);
|
||||
@ -1676,13 +1686,22 @@ static bool parse_reconnect(struct pool *pool, json_t *val)
|
||||
|
||||
sprintf(address, "%s:%s", url, port);
|
||||
|
||||
if (!extract_sockaddr(address, &pool->sockaddr_url, &pool->stratum_port))
|
||||
if (!extract_sockaddr(address, &sockaddr_url, &stratum_port))
|
||||
return false;
|
||||
|
||||
pool->stratum_url = pool->sockaddr_url;
|
||||
|
||||
applog(LOG_NOTICE, "Reconnect requested from %s to %s", pool->poolname, address);
|
||||
|
||||
mutex_lock(&pool->stratum_lock);
|
||||
__suspend_stratum(pool);
|
||||
tmp = pool->sockaddr_url;
|
||||
pool->sockaddr_url = sockaddr_url;
|
||||
pool->stratum_url = pool->sockaddr_url;
|
||||
free(tmp);
|
||||
tmp = pool->stratum_port;
|
||||
pool->stratum_port = stratum_port;
|
||||
free(tmp);
|
||||
mutex_unlock(&pool->stratum_lock);
|
||||
|
||||
if (!restart_stratum(pool))
|
||||
return false;
|
||||
|
||||
@ -2268,14 +2287,10 @@ out:
|
||||
|
||||
void suspend_stratum(struct pool *pool)
|
||||
{
|
||||
clear_sockbuf(pool);
|
||||
applog(LOG_INFO, "Closing socket for stratum %s", pool->poolname);
|
||||
|
||||
mutex_lock(&pool->stratum_lock);
|
||||
pool->stratum_active = pool->stratum_notify = false;
|
||||
if (pool->sock)
|
||||
CLOSESOCKET(pool->sock);
|
||||
pool->sock = 0;
|
||||
__suspend_stratum(pool);
|
||||
mutex_unlock(&pool->stratum_lock);
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user