Browse Source

Discard all staged work from stratum pools as well as the shares upon disconnection since all the work becomes invalid.

nfactor-troky
Con Kolivas 12 years ago
parent
commit
8dbb3fa2f9
  1. 21
      cgminer.c

21
cgminer.c

@ -4499,6 +4499,23 @@ static void clear_stratum_shares(struct pool *pool) @@ -4499,6 +4499,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)
@ -4554,6 +4571,9 @@ static void *stratum_thread(void *userdata) @@ -4554,6 +4571,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);
@ -4587,6 +4607,7 @@ static void *stratum_thread(void *userdata) @@ -4587,6 +4607,7 @@ 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 (initiate_stratum(pool) && auth_stratum(pool))
continue;

Loading…
Cancel
Save