Revert "Don't wait on select when first detecting stratum, just receive one line." This reverts commit 496af92afd3e2cfe0d507e7199bc35b17ecee766. Not quite right.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46
diff --git a/util.c b/util.c
index 13fc2bb..0afd6fb 100644
--- a/util.c
+++ b/util.c
@@ -897,14 +897,18 @@ static void clear_sock(SOCKETTYPE sock)
}
/* Check to see if Santa's been good to you */
-static bool sock_full(SOCKETTYPE sock)
+static bool sock_full(SOCKETTYPE sock, bool wait)
{
struct timeval timeout;
fd_set rd;
FD_ZERO(&rd);
FD_SET(sock, &rd);
- timeout.tv_usec = timeout.tv_sec = 0;
+ timeout.tv_usec = 0;
+ if (wait)
+ timeout.tv_sec = 60;
+ else
+ timeout.tv_sec = 0;
if (select(sock + 1, &rd, NULL, NULL, &timeout) > 0)
return true;
return false;
@@ -1137,7 +1141,7 @@ bool auth_stratum(struct pool *pool)
swork_id++, pool->rpc_user, pool->rpc_pass);
/* Parse all data prior sending auth request */
- while (sock_full(pool->sock)) {
+ while (sock_full(pool->sock, false)) {
sret = recv_line(pool->sock);
if (!parse_method(pool, sret)) {
clear_sock(pool->sock);
@@ -1208,6 +1212,11 @@ bool initiate_stratum(struct pool *pool)
goto out;
}
+ if (!sock_full(pool->sock, true)) {
+ applog(LOG_DEBUG, "Timed out waiting for response in initiate_stratum");
+ goto out;
+ }
+
sret = recv_line(pool->sock);
if (!sret)
goto out;