Commit f9123f0587ef5cf7afdc3e58ec631f423e0f705d

Con Kolivas 2012-04-29T08:55:59

Make sure to start the getwork and submit threads when a pool is added on the fly.

diff --git a/cgminer.c b/cgminer.c
index af53532..84e8c98 100644
--- a/cgminer.c
+++ b/cgminer.c
@@ -384,16 +384,12 @@ static void add_pool(void)
 	struct pool *pool;
 
 	pool = calloc(sizeof(struct pool), 1);
-	if (!pool) {
-		applog(LOG_ERR, "Failed to malloc pool in add_pool");
-		exit (1);
-	}
+	if (!pool)
+		quit(1, "Failed to malloc pool in add_pool");
 	pool->pool_no = pool->prio = total_pools;
 	pools[total_pools++] = pool;
-	if (unlikely(pthread_mutex_init(&pool->pool_lock, NULL))) {
-		applog(LOG_ERR, "Failed to pthread_mutex_init in add_pool");
-		exit (1);
-	}
+	if (unlikely(pthread_mutex_init(&pool->pool_lock, NULL)))
+		quit(1, "Failed to pthread_mutex_init in add_pool");
 	/* Make sure the pool doesn't think we've been idle since time 0 */
 	pool->tv_idle.tv_sec = ~0UL;
 
@@ -4457,6 +4453,11 @@ int add_pool_details(bool live, char *url, char *user, char *pass)
 
 	pool->tv_idle.tv_sec = ~0UL;
 
+	if (unlikely(pthread_create(&pool->submit_thread, NULL, submit_work_thread, (void *)pool)))
+		quit(1, "Failed to create pool submit thread");
+	if (unlikely(pthread_create(&pool->getwork_thread, NULL, get_work_thread, (void *)pool)))
+		quit(1, "Failed to create pool getwork thread");
+
 	/* Test the pool is not idle if we're live running, otherwise
 	 * it will be tested separately */
 	pool->enabled = true;