Browse Source

sshare could have already been free'd by parse_stratum_response in stratum_rthread by the point we reach this code - possible segfault fixed

djm34
Jan Berdajs 11 years ago
parent
commit
04722e2517
  1. 22
      sgminer.c

22
sgminer.c

@ -5451,14 +5451,23 @@ static void *stratum_sthread(void *userdata)
bool sessionid_match; bool sessionid_match;
if (likely(stratum_send(pool, s, strlen(s)))) { if (likely(stratum_send(pool, s, strlen(s)))) {
if (pool_tclear(pool, &pool->submit_fail)) int ssdiff;
applog(LOG_WARNING, "%s communication resumed, submitting work", get_pool_name(pool));
sshare->sshare_sent = time(NULL);
ssdiff = sshare->sshare_sent - sshare->sshare_time;
if (opt_debug || ssdiff > 0) {
applog(LOG_INFO, "Pool %d stratum share submission lag time %d seconds",
pool->pool_no, ssdiff);
}
mutex_lock(&sshare_lock); mutex_lock(&sshare_lock);
HASH_ADD_INT(stratum_shares, id, sshare); HASH_ADD_INT(stratum_shares, id, sshare);
pool->sshares++; pool->sshares++;
mutex_unlock(&sshare_lock); mutex_unlock(&sshare_lock);
if (pool_tclear(pool, &pool->submit_fail))
applog(LOG_WARNING, "%s communication resumed, submitting work", get_pool_name(pool));
applog(LOG_DEBUG, "Successfully submitted, adding to stratum_shares db"); applog(LOG_DEBUG, "Successfully submitted, adding to stratum_shares db");
submitted = true; submitted = true;
break; break;
@ -5492,15 +5501,6 @@ static void *stratum_sthread(void *userdata)
free(sshare); free(sshare);
pool->stale_shares++; pool->stale_shares++;
total_stale++; total_stale++;
} else {
int ssdiff;
sshare->sshare_sent = time(NULL);
ssdiff = sshare->sshare_sent - sshare->sshare_time;
if (opt_debug || ssdiff > 0) {
applog(LOG_INFO, "Pool %d stratum share submission lag time %d seconds",
pool->pool_no, ssdiff);
}
} }
} }

Loading…
Cancel
Save