Browse Source

Merge commit '4cde791' into cg_merges_20130304a

Conflicts:
	miner.c
Luke Dashjr 13 years ago
parent
commit
e28c7dcb75
3 changed files with 33 additions and 6 deletions
  1. 4 6
      miner.c
  2. 28 0
      util.c
  3. 1 0
      util.h

+ 4 - 6
miner.c

@@ -6015,9 +6015,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);
@@ -6057,7 +6057,7 @@ static void *stratum_thread(void *userdata)
 			if (pool == current_pool())
 				restart_threads();
 
-			if (initiate_stratum(pool) && auth_stratum(pool))
+			if (restart_stratum(pool))
 				continue;
 
 			shutdown_stratum(pool);
@@ -6208,9 +6208,7 @@ retry_stratum:
 		 * 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))
+		if (!(pool->stratum_active ? auth_stratum(pool) : restart_stratum(pool)))
 			return false;
 		init_stratum_thread(pool);
 		detect_algo = 2;

+ 28 - 0
util.c

@@ -1723,6 +1723,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);

+ 1 - 0
util.h

@@ -69,6 +69,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);