Browse Source

Merge commit 'e0196a3' into cg_merges_20130513

Luke Dashjr 13 years ago
parent
commit
3ea2ce3f28
3 changed files with 14 additions and 3 deletions
  1. 9 2
      miner.c
  2. 2 0
      miner.h
  3. 3 1
      util.c

+ 9 - 2
miner.c

@@ -7506,6 +7506,13 @@ static void *watchpool_thread(void __maybe_unused *userdata)
 			if (pool->enabled == POOL_DISABLED)
 			if (pool->enabled == POOL_DISABLED)
 				continue;
 				continue;
 
 
+			/* Don't start testing any pools if the test threads
+			 * from startup are still doing their first attempt. */
+			if (unlikely(pool->testing)) {
+				pthread_join(pool->test_thread, NULL);
+				pool->testing = false;
+			}
+
 			/* Test pool is idle once every minute */
 			/* Test pool is idle once every minute */
 			if (pool->idle && now.tv_sec - pool->tv_idle.tv_sec > 30) {
 			if (pool->idle && now.tv_sec - pool->tv_idle.tv_sec > 30) {
 				gettimeofday(&pool->tv_idle, NULL);
 				gettimeofday(&pool->tv_idle, NULL);
@@ -8235,10 +8242,10 @@ static void probe_pools(void)
 	int i;
 	int i;
 
 
 	for (i = 0; i < total_pools; i++) {
 	for (i = 0; i < total_pools; i++) {
-		pthread_t *test_thread = malloc(sizeof(pthread_t));
 		struct pool *pool = pools[i];
 		struct pool *pool = pools[i];
 
 
-		pthread_create(test_thread, NULL, test_pool_thread, (void *)pool);
+		pool->testing = true;
+		pthread_create(&pool->test_thread, NULL, test_pool_thread, (void *)pool);
 	}
 	}
 }
 }
 
 

+ 2 - 0
miner.h

@@ -1043,6 +1043,8 @@ struct pool {
 	struct thread_q *getwork_q;
 	struct thread_q *getwork_q;
 
 
 	pthread_t longpoll_thread;
 	pthread_t longpoll_thread;
+	pthread_t test_thread;
+	bool testing;
 
 
 	int curls;
 	int curls;
 	pthread_cond_t cr_cond;
 	pthread_cond_t cr_cond;

+ 3 - 1
util.c

@@ -1903,8 +1903,10 @@ bool initiate_stratum(struct pool *pool)
 	int n2size;
 	int n2size;
 
 
 resend:
 resend:
-	if (!setup_stratum_curl(pool))
+	if (!setup_stratum_curl(pool)) {
+		sockd = false;
 		goto out;
 		goto out;
+	}
 
 
 	sockd = true;
 	sockd = true;