From 6e969e93e22bbdfce04b1e0e5659040a4de825c4 Mon Sep 17 00:00:00 2001 From: Con Kolivas Date: Wed, 8 May 2013 22:52:18 +1000 Subject: [PATCH] Recv() should all be non-blocking for raw sockets in stratum. --- util.c | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/util.c b/util.c index 091b4eac..b8012803 100644 --- a/util.c +++ b/util.c @@ -1033,13 +1033,11 @@ static void clear_sock(struct pool *pool) { ssize_t n; - if (socket_full(pool, false)) { - mutex_lock(&pool->stratum_lock); - do { - n = recv(pool->sock, pool->sockbuf, RECVSIZE, 0); - } while (n > 0); - mutex_unlock(&pool->stratum_lock); - } + mutex_lock(&pool->stratum_lock); + do { + n = recv(pool->sock, pool->sockbuf, RECVSIZE, MSG_DONTWAIT); + } while (n > 0); + mutex_unlock(&pool->stratum_lock); clear_sockbuf(pool); } @@ -1095,7 +1093,7 @@ char *recv_line(struct pool *pool) ssize_t n; memset(s, 0, RBUFSIZE); - n = recv(pool->sock, s, RECVSIZE, 0); + n = recv(pool->sock, s, RECVSIZE, MSG_DONTWAIT); if (!n) { ret = RECV_CLOSED; break;