Browse Source

Merge commit 'c548ca0' into bfgminer

Conflicts:
	miner.c
Luke Dashjr 11 years ago
parent
commit
0408272572
1 changed files with 16 additions and 2 deletions
  1. 16 2
      miner.c

+ 16 - 2
miner.c

@@ -4374,8 +4374,11 @@ void logwin_update(void)
 static void enable_pool(struct pool *pool)
 {
 	if (pool->enabled != POOL_ENABLED) {
+		mutex_lock(&lp_lock);
 		enabled_pools++;
 		pool->enabled = POOL_ENABLED;
+		pthread_cond_broadcast(&lp_cond);
+		mutex_unlock(&lp_lock);
 	}
 }
 
@@ -5632,14 +5635,19 @@ out_unlock:
 
 static void pool_died(struct pool *pool)
 {
+	mutex_lock(&lp_lock);
 	if (!pool_tset(pool, &pool->idle)) {
 		cgtime(&pool->tv_idle);
+		pthread_cond_broadcast(&lp_cond);
+		mutex_unlock(&lp_lock);
 		if (pool == current_pool()) {
 			applog(LOG_WARNING, "Pool %d %s not responding!", pool->pool_no, pool->rpc_url);
 			switch_pools(NULL);
 		} else
 			applog(LOG_INFO, "Pool %d %s failed to return work", pool->pool_no, pool->rpc_url);
 	}
+	else
+		mutex_unlock(&lp_lock);
 }
 
 bool stale_work(struct work *work, bool share)
@@ -6363,6 +6371,9 @@ void switch_pools(struct pool *selected)
 
 	currentpool = pools[pool_no];
 	pool = currentpool;
+	mutex_lock(&lp_lock);
+	pthread_cond_broadcast(&lp_cond);
+	mutex_unlock(&lp_lock);
 	cg_wunlock(&control_lock);
 
 	/* Set the lagging flag to avoid pool not providing work fast enough
@@ -7286,7 +7297,10 @@ retry:
 				goto retry;
 			}
 		}
+		mutex_lock(&lp_lock);
 		pool_strategy = selected;
+		pthread_cond_broadcast(&lp_cond);
+		mutex_unlock(&lp_lock);
 		switch_pools(NULL);
 		goto updated;
 	} else if (!strncasecmp(&input, "i", 1)) {
@@ -9958,13 +9972,13 @@ struct pool *_select_longpoll_pool(struct pool *cp, bool(*func)(struct pool *))
  */
 static void wait_lpcurrent(struct pool *pool)
 {
+	mutex_lock(&lp_lock);
 	while (!cnx_needed(pool))
 	{
 		pool->lp_active = false;
-		mutex_lock(&lp_lock);
 		pthread_cond_wait(&lp_cond, &lp_lock);
-		mutex_unlock(&lp_lock);
 	}
+	mutex_unlock(&lp_lock);
 }
 
 static curl_socket_t save_curl_socket(void *vpool, __maybe_unused curlsocktype purpose, struct curl_sockaddr *addr) {