|
|
@@ -162,7 +162,9 @@ static pthread_mutex_t *stgd_lock;
|
|
|
#ifdef HAVE_CURSES
|
|
|
static pthread_mutex_t curses_lock;
|
|
|
#endif
|
|
|
+static pthread_mutex_t ch_lock;
|
|
|
static pthread_rwlock_t blk_lock;
|
|
|
+
|
|
|
pthread_rwlock_t netacc_lock;
|
|
|
|
|
|
double total_mhashes_done;
|
|
|
@@ -2156,13 +2158,13 @@ static void *submit_work_thread(void *userdata)
|
|
|
|
|
|
if (stale_work(work, true)) {
|
|
|
if (pool->submit_old)
|
|
|
- applog(LOG_NOTICE, "Stale share detected, submitting as pool %d requested",
|
|
|
+ applog(LOG_NOTICE, "Stale share, submitting as pool %d requested",
|
|
|
pool->pool_no);
|
|
|
else if (opt_submit_stale)
|
|
|
- applog(LOG_NOTICE, "Stale share detected from pool %d, submitting as user requested",
|
|
|
+ applog(LOG_NOTICE, "Stale share from pool %d, submitting as user requested",
|
|
|
pool->pool_no);
|
|
|
else {
|
|
|
- applog(LOG_NOTICE, "Stale share detected from pool %d, discarding",
|
|
|
+ applog(LOG_NOTICE, "Stale share from pool %d, discarding",
|
|
|
pool->pool_no);
|
|
|
sharelog("discard", work);
|
|
|
total_stale++;
|
|
|
@@ -2437,23 +2439,25 @@ static void restart_threads(void)
|
|
|
static void set_curblock(char *hexstr, unsigned char *hash)
|
|
|
{
|
|
|
unsigned char hash_swap[32];
|
|
|
- char *old_hash = NULL;
|
|
|
struct timeval tv_now;
|
|
|
+ char *old_hash;
|
|
|
|
|
|
- /* Don't free current_hash directly to avoid dereferencing it when
|
|
|
- * we might be accessing its data elsewhere */
|
|
|
- if (current_hash)
|
|
|
- old_hash = current_hash;
|
|
|
strcpy(current_block, hexstr);
|
|
|
gettimeofday(&tv_now, NULL);
|
|
|
get_timestamp(blocktime, &tv_now);
|
|
|
swap256(hash_swap, hash);
|
|
|
+
|
|
|
+ /* Don't free current_hash directly to avoid dereferencing when read
|
|
|
+ * elsewhere */
|
|
|
+ mutex_lock(&ch_lock);
|
|
|
+ old_hash = current_hash;
|
|
|
current_hash = bin2hex(hash_swap, 16);
|
|
|
+ free(old_hash);
|
|
|
+ mutex_unlock(&ch_lock);
|
|
|
+
|
|
|
if (unlikely(!current_hash))
|
|
|
quit (1, "set_curblock OOM");
|
|
|
applog(LOG_INFO, "New block: %s...", current_hash);
|
|
|
- if (old_hash)
|
|
|
- free(old_hash);
|
|
|
}
|
|
|
|
|
|
/* Search to see if this string is from a block that has been seen before */
|
|
|
@@ -4768,6 +4772,7 @@ int main(int argc, char *argv[])
|
|
|
#endif
|
|
|
mutex_init(&control_lock);
|
|
|
mutex_init(&sharelog_lock);
|
|
|
+ mutex_init(&ch_lock);
|
|
|
rwlock_init(&blk_lock);
|
|
|
rwlock_init(&netacc_lock);
|
|
|
|