Browse Source

Merge branch 'bugfix_cnx_needed_forshares' into bfgminer

Luke Dashjr 13 years ago
parent
commit
797d305a1a
2 changed files with 9 additions and 0 deletions
  1. 8 0
      miner.c
  2. 1 0
      miner.h

+ 8 - 0
miner.c

@@ -3451,6 +3451,7 @@ retry:
 			}
 		}
 		ret_work = make_work();
+		pool->last_work_time = time(NULL);
 		gen_stratum_work(pool, ret_work);
 		if (unlikely(!stage_work(ret_work))) {
 			applog(LOG_ERR, "Failed to stage stratum work in get_work_thread");
@@ -5495,6 +5496,12 @@ static bool cnx_needed(struct pool *pool)
 		return true;
 	if (!cp->has_stratum && (!opt_fail_only || !cp->hdr_path))
 		return true;
+
+	/* Keep stratum pools alive until at least a minute after their last
+	 * generated work, to ensure we have a channel for any submissions */
+	if (pool->has_stratum && difftime(time(NULL), pool->last_work_time) < 60)
+		return true;
+
 	return false;
 }
 
@@ -5936,6 +5943,7 @@ static bool reuse_work(struct work *work, struct pool *pool)
 		if (!pool->stratum_active)
 			return false;
 		applog(LOG_DEBUG, "Reusing stratum work");
+		pool->last_work_time = time(NULL);
 		gen_stratum_work(pool, work);
 		return true;
 	}

+ 1 - 0
miner.h

@@ -999,6 +999,7 @@ struct pool {
 	int n2size;
 	bool has_stratum;
 	bool stratum_active;
+	time_t last_work_time;  /* only set for Stratum right now */
 	bool stratum_auth;
 	struct stratum_work swork;
 	pthread_t stratum_thread;