From 04722e2517ba2c9a67e33c6c51a5c86855f30e5c Mon Sep 17 00:00:00 2001 From: Jan Berdajs Date: Tue, 8 Jul 2014 05:49:12 +0200 Subject: [PATCH] sshare could have already been free'd by parse_stratum_response in stratum_rthread by the point we reach this code - possible segfault fixed --- sgminer.c | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/sgminer.c b/sgminer.c index fa65cdfe..a84eb7db 100644 --- a/sgminer.c +++ b/sgminer.c @@ -5451,14 +5451,23 @@ static void *stratum_sthread(void *userdata) bool sessionid_match; if (likely(stratum_send(pool, s, strlen(s)))) { - if (pool_tclear(pool, &pool->submit_fail)) - applog(LOG_WARNING, "%s communication resumed, submitting work", get_pool_name(pool)); + 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); + } mutex_lock(&sshare_lock); HASH_ADD_INT(stratum_shares, id, sshare); pool->sshares++; 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"); submitted = true; break; @@ -5492,15 +5501,6 @@ static void *stratum_sthread(void *userdata) free(sshare); pool->stale_shares++; 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); - } } }