Browse Source

Merge commit 'a07e015' into cg_merges_20121219

Luke Dashjr 13 years ago
parent
commit
7b291da674
1 changed files with 23 additions and 0 deletions
  1. 23 0
      miner.c

+ 23 - 0
miner.c

@@ -5475,6 +5475,23 @@ static void clear_stratum_shares(struct pool *pool)
 	}
 }
 
+static void clear_pool_work(struct pool *pool)
+{
+	struct work *work, *tmp;
+	int cleared = 0;
+
+	mutex_lock(stgd_lock);
+	HASH_ITER(hh, staged_work, work, tmp) {
+		if (work->pool == pool) {
+			HASH_DEL(staged_work, work);
+			free_work(work);
+			cleared++;
+		}
+	}
+	mutex_unlock(stgd_lock);
+	applog(LOG_ERR, "Discarded %d stratum works", cleared);
+}
+
 /* We only need to maintain a secondary pool connection when we need the
  * capacity to get work from the backup pools while still on the primary */
 static bool cnx_needed(struct pool *pool)
@@ -5538,6 +5555,9 @@ static void *stratum_thread(void *userdata)
 		 * pool */
 		if (!cnx_needed(pool)) {
 			suspend_stratum(pool);
+			clear_stratum_shares(pool);
+			clear_pool_work(pool);
+
 			wait_lpcurrent(pool);
 			if (!initiate_stratum(pool) || !auth_stratum(pool)) {
 				pool_died(pool);
@@ -5578,6 +5598,9 @@ static void *stratum_thread(void *userdata)
 			 * tracked submitted shares are lost and we will leak
 			 * the memory if we don't discard their records. */
 			clear_stratum_shares(pool);
+			clear_pool_work(pool);
+			if (pool == current_pool())
+				restart_threads();
 
 			if (initiate_stratum(pool) && auth_stratum(pool))
 				continue;