mirror of
https://github.com/GOSTSec/sgminer
synced 2025-02-02 10:04:33 +00:00
Clear just the socket buffer when we don't care what is left in a stratum socket.
This commit is contained in:
parent
fbb25c4ba5
commit
ed903ddf31
14
util.c
14
util.c
@ -981,16 +981,22 @@ bool sock_full(struct pool *pool)
|
|||||||
return (socket_full(pool, false));
|
return (socket_full(pool, false));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void clear_sockbuf(struct pool *pool)
|
||||||
|
{
|
||||||
|
strcpy(pool->sockbuf, "");
|
||||||
|
}
|
||||||
|
|
||||||
static void clear_sock(struct pool *pool)
|
static void clear_sock(struct pool *pool)
|
||||||
{
|
{
|
||||||
ssize_t n;
|
ssize_t n;
|
||||||
|
|
||||||
mutex_lock(&pool->stratum_lock);
|
mutex_lock(&pool->stratum_lock);
|
||||||
do
|
do {
|
||||||
n = recv(pool->sock, pool->sockbuf, RECVSIZE, 0);
|
n = recv(pool->sock, pool->sockbuf, RECVSIZE, 0);
|
||||||
while (n > 0);
|
} while (n > 0);
|
||||||
mutex_unlock(&pool->stratum_lock);
|
mutex_unlock(&pool->stratum_lock);
|
||||||
strcpy(pool->sockbuf, "");
|
|
||||||
|
clear_sockbuf(pool);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Make sure the pool sockbuf is large enough to cope with any coinbase size
|
/* Make sure the pool sockbuf is large enough to cope with any coinbase size
|
||||||
@ -1506,7 +1512,7 @@ out:
|
|||||||
|
|
||||||
void suspend_stratum(struct pool *pool)
|
void suspend_stratum(struct pool *pool)
|
||||||
{
|
{
|
||||||
clear_sock(pool);
|
clear_sockbuf(pool);
|
||||||
applog(LOG_INFO, "Closing socket for stratum pool %d", pool->pool_no);
|
applog(LOG_INFO, "Closing socket for stratum pool %d", pool->pool_no);
|
||||||
mutex_lock(&pool->stratum_lock);
|
mutex_lock(&pool->stratum_lock);
|
||||||
pool->stratum_active = pool->stratum_notify = false;
|
pool->stratum_active = pool->stratum_notify = false;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user