Browse Source

Merge branch 'auto_solomine' into bfgminer

Luke Dashjr 9 years ago
parent
commit
3c4348da3d
2 changed files with 10 additions and 0 deletions
  1. 5 0
      miner.c
  2. 5 0
      miner.h

+ 5 - 0
miner.c

@@ -3432,22 +3432,27 @@ void refresh_bitcoind_address(struct mining_goal_info * const goal, const bool f
 			json_decref(json);
 			continue;
 		}
+		cg_ilock(&control_lock);
 		if (goal->generation_script)
 		{
 			if (bytes_eq(&newscript, goal->generation_script))
 			{
+				cg_iunlock(&control_lock);
 				applog(LOG_DEBUG, "Pool %d returned coinbase address already in use (%s)", pool->pool_no, s);
 				json_decref(json);
 				break;
 			}
+			cg_ulock(&control_lock);
 		}
 		else
 		{
+			cg_ulock(&control_lock);
 			goal->generation_script = malloc(sizeof(*goal->generation_script));
 			bytes_init(goal->generation_script);
 		}
 		bytes_assimilate(goal->generation_script, &newscript);
 		coinbase_script_block_id = blkchain->currentblk->block_id;
+		cg_wunlock(&control_lock);
 		applog(LOG_NOTICE, "Now using coinbase address %s, provided by pool %d", s, pool->pool_no);
 		json_decref(json);
 		break;

+ 5 - 0
miner.h

@@ -954,6 +954,11 @@ static inline void cg_runlock(cglock_t *lock)
 	rd_unlock(&lock->rwlock);
 }
 
+static inline void cg_iunlock(cglock_t *lock)
+{
+	mutex_unlock(&lock->mutex);
+}
+
 static inline void cg_wunlock(cglock_t *lock)
 {
 	wr_unlock_noyield(&lock->rwlock);