Make sure to start the getwork and submit threads when a pool is added on the fly.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37
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;