Make the initialisation of the stratum thread more robust allowing the watchpool thread safe access to it after the stratum thread is started.
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 38 39 40 41 42 43 44 45 46 47 48 49 50 51
diff --git a/cgminer.c b/cgminer.c
index f073f9e..2d5d089 100644
--- a/cgminer.c
+++ b/cgminer.c
@@ -4988,22 +4988,19 @@ static bool pool_active(struct pool *pool, bool pinging)
retry_stratum:
if (pool->has_stratum) {
/* We create the stratum thread for each pool just after
- * successful authorisation. Once the auth flag has been set
+ * successful authorisation. Once the init flag has been set
* we never unset it and the stratum thread is responsible for
* setting/unsetting the active flag */
- if (pool->stratum_auth)
- return pool->stratum_active;
- if (!pool->stratum_active && !initiate_stratum(pool))
- return false;
- if (!auth_stratum(pool))
- return false;
- /* Only set stratum_auth once to prevent multiple threads
- * being started */
- if (pool_tset(pool, &pool->stratum_auth))
- return true;
- pool->idle = false;
- init_stratum_thread(pool);
- return true;
+ bool init = pool_tset(pool, &pool->stratum_init);
+
+ if (!init) {
+ bool ret = initiate_stratum(pool) && auth_stratum(pool);
+
+ pool->idle = ret;
+ init_stratum_thread(pool);
+ return ret;
+ }
+ return pool->stratum_active;
}
curl = curl_easy_init();
diff --git a/miner.h b/miner.h
index 0c65d9c..00291be 100644
--- a/miner.h
+++ b/miner.h
@@ -997,7 +997,7 @@ struct pool {
char *sessionid;
bool has_stratum;
bool stratum_active;
- bool stratum_auth;
+ bool stratum_init;
bool stratum_notify;
struct stratum_work swork;
pthread_t stratum_thread;