Provide basic framework for restarting stratum depending on whether resume support exists or not.
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 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81
diff --git a/cgminer.c b/cgminer.c
index 47496df..a896cfc 100644
--- a/cgminer.c
+++ b/cgminer.c
@@ -4720,9 +4720,9 @@ static void *stratum_thread(void *userdata)
clear_pool_work(pool);
wait_lpcurrent(pool);
- if (!initiate_stratum(pool) || !auth_stratum(pool)) {
+ if (!restart_stratum(pool)) {
pool_died(pool);
- while (!initiate_stratum(pool) || !auth_stratum(pool)) {
+ while (!restart_stratum(pool)) {
if (pool->removed)
goto out;
sleep(30);
@@ -4757,11 +4757,11 @@ static void *stratum_thread(void *userdata)
if (pool == current_pool())
restart_threads();
- if (initiate_stratum(pool) && auth_stratum(pool))
+ if (restart_stratum(pool))
continue;
pool_died(pool);
- while (!initiate_stratum(pool) || !auth_stratum(pool)) {
+ while (!restart_stratum(pool)) {
if (pool->removed)
goto out;
sleep(30);
diff --git a/util.c b/util.c
index 77f5b36..48d3bd9 100644
--- a/util.c
+++ b/util.c
@@ -1513,6 +1513,34 @@ out:
return ret;
}
+/* Placeholder for real resume function in the future */
+static bool resume_stratum(struct pool *pool)
+{
+ mutex_lock(&pool->pool_lock);
+ free(pool->sessionid);
+ pool->sessionid = NULL;
+ mutex_unlock(&pool->pool_lock);
+
+ return false;
+}
+
+bool restart_stratum(struct pool *pool)
+{
+ bool resume;
+
+ mutex_lock(&pool->pool_lock);
+ resume = pool->sessionid != NULL;
+ mutex_unlock(&pool->pool_lock);
+
+ if (resume && !resume_stratum(pool))
+ return false;
+ else if (!initiate_stratum(pool))
+ return false;
+ if (!auth_stratum(pool))
+ return false;
+ return true;
+}
+
void suspend_stratum(struct pool *pool)
{
applog(LOG_INFO, "Closing socket for stratum pool %d", pool->pool_no);
diff --git a/util.h b/util.h
index ade0b2e..9093b76 100644
--- a/util.h
+++ b/util.h
@@ -52,6 +52,7 @@ bool parse_method(struct pool *pool, char *s);
bool extract_sockaddr(struct pool *pool, char *url);
bool auth_stratum(struct pool *pool);
bool initiate_stratum(struct pool *pool);
+bool restart_stratum(struct pool *pool);
void suspend_stratum(struct pool *pool);
void dev_error(struct cgpu_info *dev, enum dev_reason reason);
void *realloc_strcat(char *ptr, char *s);