Browse Source

Bugfix: Stratum: Avoid FD_SETting INVSOCK

Conflicts:
	miner.c
Luke Dashjr 12 years ago
parent
commit
5e59c89557
2 changed files with 9 additions and 3 deletions
  1. 6 3
      miner.c
  2. 3 0
      util.c

+ 6 - 3
miner.c

@@ -6215,14 +6215,17 @@ static void *stratum_thread(void *userdata)
 		struct timeval timeout;
 		struct timeval timeout;
 		fd_set rd;
 		fd_set rd;
 		char *s;
 		char *s;
+		int sock;
 
 
 		if (unlikely(!pool->has_stratum))
 		if (unlikely(!pool->has_stratum))
 			break;
 			break;
 
 
+		sock = pool->sock;
+		
 		/* 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) && !cnx_needed(pool)) {
+		if (sock == INVSOCK || (!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);
@@ -6239,14 +6242,14 @@ static void *stratum_thread(void *userdata)
 		}
 		}
 
 
 		FD_ZERO(&rd);
 		FD_ZERO(&rd);
-		FD_SET(pool->sock, &rd);
+		FD_SET(sock, &rd);
 		timeout.tv_sec = 120;
 		timeout.tv_sec = 120;
 		timeout.tv_usec = 0;
 		timeout.tv_usec = 0;
 
 
 		/* 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) && select(pool->sock + 1, &rd, NULL, NULL, &timeout) < 1) {
+		if (!sock_full(pool) && select(sock + 1, &rd, NULL, NULL, &timeout) < 1) {
 			applog(LOG_DEBUG, "Stratum select timeout on pool %d", pool->pool_no);
 			applog(LOG_DEBUG, "Stratum select timeout on pool %d", pool->pool_no);
 			s = NULL;
 			s = NULL;
 		} else
 		} else

+ 3 - 0
util.c

@@ -1196,6 +1196,9 @@ static bool socket_full(struct pool *pool, int wait)
 	struct timeval timeout;
 	struct timeval timeout;
 	fd_set rd;
 	fd_set rd;
 
 
+	if (sock == INVSOCK)
+		return true;
+	
 	if (unlikely(wait < 0))
 	if (unlikely(wait < 0))
 		wait = 0;
 		wait = 0;
 	FD_ZERO(&rd);
 	FD_ZERO(&rd);