Browse Source

Differentiate socket full from sock full.

Conflicts:

	miner.c
	util.c
Con Kolivas 13 years ago
parent
commit
6d209b17e0
3 changed files with 15 additions and 10 deletions
  1. 1 1
      miner.c
  2. 13 8
      util.c
  3. 1 1
      util.h

+ 1 - 1
miner.c

@@ -5502,7 +5502,7 @@ static void *stratum_thread(void *userdata)
 		/* If we fail to receive any notify messages for 2 minutes 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);

+ 13 - 8
util.c

@@ -921,16 +921,12 @@ static void clear_sock(struct pool *pool)
 	mutex_unlock(&pool->stratum_lock);
 }
 
-/* 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 (pool->readbuf.buf && memchr(pool->readbuf.buf, '\n', pool->readbuf.len))
-		return true;
-
 	FD_ZERO(&rd);
 	FD_SET(sock, &rd);
 	timeout.tv_usec = 0;
@@ -943,6 +939,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 (pool->readbuf.buf && memchr(pool->readbuf.buf, '\n', pool->readbuf.len))
+		return true;
+
+	return (socket_full(pool, false));
+}
+
 /* Peeks at a socket to find the first end of line and then reads just that
  * from the socket and returns that as a malloced char */
 char *recv_line(struct pool *pool)
@@ -955,8 +960,8 @@ char *recv_line(struct pool *pool)
 		char s[RBUFSIZE];
 		CURLcode rc;
 
-		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);
@@ -1369,7 +1374,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;
 	}

+ 1 - 1
util.h

@@ -44,7 +44,7 @@
 
 struct pool;
 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);