Browse Source

Merge commit '6e2e7d3' into cg_merges_20121231

Conflicts:
	util.c
Luke Dashjr 13 years ago
parent
commit
929de15e5b
3 changed files with 16 additions and 11 deletions
  1. 2 2
      miner.c
  2. 13 8
      util.c
  3. 1 1
      util.h

+ 2 - 2
miner.c

@@ -5684,7 +5684,7 @@ static void *stratum_thread(void *userdata)
 		/* Check to see whether we need to maintain this connection
 		/* Check to see whether we need to maintain this connection
 		 * indefinitely or just bring it up when we switch to this
 		 * indefinitely or just bring it up when we switch to this
 		 * pool */
 		 * pool */
-		if (!sock_full(pool, false) && !cnx_needed(pool)) {
+		if (!sock_full(pool) && !cnx_needed(pool)) {
 			suspend_stratum(pool);
 			suspend_stratum(pool);
 			clear_stratum_shares(pool);
 			clear_stratum_shares(pool);
 			clear_pool_work(pool);
 			clear_pool_work(pool);
@@ -5708,7 +5708,7 @@ static void *stratum_thread(void *userdata)
 		/* If we fail to receive any notify messages for 2 minutes we
 		/* If we fail to receive any notify messages for 2 minutes we
 		 * assume the connection has been dropped and treat this pool
 		 * assume the connection has been dropped and treat this pool
 		 * as dead */
 		 * 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;
 			s = NULL;
 		else
 		else
 			s = recv_line(pool);
 			s = recv_line(pool);

+ 13 - 8
util.c

@@ -1023,16 +1023,12 @@ bool stratum_send(struct pool *pool, char *s, ssize_t len)
 	return ret;
 	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;
 	SOCKETTYPE sock = pool->sock;
 	struct timeval timeout;
 	struct timeval timeout;
 	fd_set rd;
 	fd_set rd;
 
 
-	if (pool->readbuf.buf && memchr(pool->readbuf.buf, '\n', pool->readbuf.len))
-		return true;
-
 	FD_ZERO(&rd);
 	FD_ZERO(&rd);
 	FD_SET(sock, &rd);
 	FD_SET(sock, &rd);
 	timeout.tv_usec = 0;
 	timeout.tv_usec = 0;
@@ -1045,6 +1041,15 @@ bool sock_full(struct pool *pool, bool wait)
 	return false;
 	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));
+}
+
 static void clear_sock(struct pool *pool)
 static void clear_sock(struct pool *pool)
 {
 {
 	ssize_t n;
 	ssize_t n;
@@ -1069,8 +1074,8 @@ char *recv_line(struct pool *pool)
 	while (!(pool->readbuf.buf && memchr(pool->readbuf.buf, '\n', pool->readbuf.len))) {
 	while (!(pool->readbuf.buf && memchr(pool->readbuf.buf, '\n', pool->readbuf.len))) {
 		char s[RBUFSIZE];
 		char s[RBUFSIZE];
 
 
-		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;
 			goto out;
 		}
 		}
 		memset(s, 0, RBUFSIZE);
 		memset(s, 0, RBUFSIZE);
@@ -1506,7 +1511,7 @@ bool initiate_stratum(struct pool *pool)
 		goto out;
 		goto out;
 	}
 	}
 
 
-	if (!sock_full(pool, true)) {
+	if (!socket_full(pool, true)) {
 		applog(LOG_DEBUG, "Timed out waiting for response in initiate_stratum");
 		applog(LOG_DEBUG, "Timed out waiting for response in initiate_stratum");
 		goto out;
 		goto out;
 	}
 	}

+ 1 - 1
util.h

@@ -59,7 +59,7 @@ extern bool hash_target_check(const unsigned char *hash, const unsigned char *ta
 extern bool hash_target_check_v(const unsigned char *hash, const unsigned char *target);
 extern bool hash_target_check_v(const unsigned char *hash, const unsigned char *target);
 
 
 bool stratum_send(struct pool *pool, char *s, ssize_t len);
 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);
 char *recv_line(struct pool *pool);
 bool parse_method(struct pool *pool, char *s);
 bool parse_method(struct pool *pool, char *s);
 bool extract_sockaddr(struct pool *pool, char *url);
 bool extract_sockaddr(struct pool *pool, char *url);