Commit 6e2e7d36deeb90aaac945397d12ba446a76861a5

Con Kolivas 2012-12-29T10:46:55

Differentiate socket full from sock full.

diff --git a/cgminer.c b/cgminer.c
index 9f82bf3..41cf4e8 100644
--- a/cgminer.c
+++ b/cgminer.c
@@ -4655,7 +4655,7 @@ static void *stratum_thread(void *userdata)
 		/* Check to see whether we need to maintain this connection
 		 * indefinitely or just bring it up when we switch to this
 		 * pool */
-		if (!sock_full(pool, false) && !cnx_needed(pool)) {
+		if (!sock_full(pool) && !cnx_needed(pool)) {
 			suspend_stratum(pool);
 			clear_stratum_shares(pool);
 			clear_pool_work(pool);
@@ -4680,7 +4680,7 @@ static void *stratum_thread(void *userdata)
 		 * every minute so if we fail to receive any for 90 seconds we
 		 * assume the connection has been dropped and treat this pool
 		 * as dead */
-		if (!sock_full(pool, false) && select(pool->sock + 1, &rd, NULL, NULL, &timeout) < 1)
+		if (!sock_full(pool) && select(pool->sock + 1, &rd, NULL, NULL, &timeout) < 1)
 			s = NULL;
 		else
 			s = recv_line(pool);
diff --git a/util.c b/util.c
index 2ac4b88..9ca31d6 100644
--- a/util.c
+++ b/util.c
@@ -929,16 +929,12 @@ bool stratum_send(struct pool *pool, char *s, ssize_t len)
 	return ret;
 }
 
-/* Check to see if Santa's been good to you */
-bool sock_full(struct pool *pool, bool wait)
+static bool socket_full(struct pool *pool, bool wait)
 {
 	SOCKETTYPE sock = pool->sock;
 	struct timeval timeout;
 	fd_set rd;
 
-	if (strlen(pool->sockbuf))
-		return true;
-
 	FD_ZERO(&rd);
 	FD_SET(sock, &rd);
 	timeout.tv_usec = 0;
@@ -951,6 +947,15 @@ bool sock_full(struct pool *pool, bool wait)
 	return false;
 }
 
+/* Check to see if Santa's been good to you */
+bool sock_full(struct pool *pool)
+{
+	if (strlen(pool->sockbuf))
+		return true;
+
+	return (socket_full(pool, false));
+}
+
 static void clear_sock(struct pool *pool)
 {
 	ssize_t n;
@@ -975,8 +980,8 @@ char *recv_line(struct pool *pool)
 		char s[RBUFSIZE];
 		size_t sspace;
 
-		if (!sock_full(pool, true)) {
-			applog(LOG_DEBUG, "Timed out waiting for data on sock_full");
+		if (!socket_full(pool, true)) {
+			applog(LOG_DEBUG, "Timed out waiting for data on socket_full");
 			goto out;
 		}
 		memset(s, 0, RBUFSIZE);
@@ -1385,7 +1390,7 @@ bool initiate_stratum(struct pool *pool)
 		goto out;
 	}
 
-	if (!sock_full(pool, true)) {
+	if (!socket_full(pool, true)) {
 		applog(LOG_DEBUG, "Timed out waiting for response in initiate_stratum");
 		goto out;
 	}
diff --git a/util.h b/util.h
index ed4c9f5..620dcda 100644
--- a/util.h
+++ b/util.h
@@ -46,7 +46,7 @@ struct pool;
 enum dev_reason;
 struct cgpu_info;
 bool stratum_send(struct pool *pool, char *s, ssize_t len);
-bool sock_full(struct pool *pool, bool wait);
+bool sock_full(struct pool *pool);
 char *recv_line(struct pool *pool);
 bool parse_method(struct pool *pool, char *s);
 bool extract_sockaddr(struct pool *pool, char *url);