Browse Source

Bugfix: Only add new pools to array after completing basic structure initialization

Luke Dashjr 13 years ago
parent
commit
93ca91758e
1 changed files with 3 additions and 2 deletions
  1. 3 2
      cgminer.c

+ 3 - 2
cgminer.c

@@ -395,8 +395,6 @@ static struct pool *add_pool(void)
 	if (!pool)
 	if (!pool)
 		quit(1, "Failed to malloc pool in add_pool");
 		quit(1, "Failed to malloc pool in add_pool");
 	pool->pool_no = pool->prio = total_pools;
 	pool->pool_no = pool->prio = total_pools;
-	pools = realloc(pools, sizeof(struct pool *) * (total_pools + 2));
-	pools[total_pools++] = pool;
 	if (unlikely(pthread_mutex_init(&pool->pool_lock, NULL)))
 	if (unlikely(pthread_mutex_init(&pool->pool_lock, NULL)))
 		quit(1, "Failed to pthread_mutex_init in add_pool");
 		quit(1, "Failed to pthread_mutex_init in add_pool");
 	if (unlikely(pthread_cond_init(&pool->cr_cond, NULL)))
 	if (unlikely(pthread_cond_init(&pool->cr_cond, NULL)))
@@ -406,6 +404,9 @@ static struct pool *add_pool(void)
 	/* Make sure the pool doesn't think we've been idle since time 0 */
 	/* Make sure the pool doesn't think we've been idle since time 0 */
 	pool->tv_idle.tv_sec = ~0UL;
 	pool->tv_idle.tv_sec = ~0UL;
 
 
+	pools = realloc(pools, sizeof(struct pool *) * (total_pools + 2));
+	pools[total_pools++] = pool;
+
 	return pool;
 	return pool;
 }
 }