Browse Source

Parse anything in the stratum socket if it's full without waiting.

Con Kolivas 13 years ago
parent
commit
d68a1cabb6
3 changed files with 3 additions and 2 deletions
  1. 1 1
      miner.c
  2. 1 1
      util.c
  3. 1 0
      util.h

+ 1 - 1
miner.c

@@ -5493,7 +5493,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 (unlikely(select(pool->sock + 1, &rd, NULL, NULL, &timeout) < 1))
+		if (!sock_full(pool, false) && select(pool->sock + 1, &rd, NULL, NULL, &timeout) < 1)
 			s = NULL;
 			s = NULL;
 		else
 		else
 			s = recv_line(pool);
 			s = recv_line(pool);

+ 1 - 1
util.c

@@ -922,7 +922,7 @@ static void clear_sock(struct pool *pool)
 }
 }
 
 
 /* Check to see if Santa's been good to you */
 /* Check to see if Santa's been good to you */
-static bool sock_full(struct pool *pool, bool wait)
+bool sock_full(struct pool *pool, bool wait)
 {
 {
 	SOCKETTYPE sock = pool->sock;
 	SOCKETTYPE sock = pool->sock;
 	struct timeval timeout;
 	struct timeval timeout;

+ 1 - 0
util.h

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