aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBas van Kervel <bas@ethdev.com>2015-09-08 18:42:29 +0800
committerBas van Kervel <bas@ethdev.com>2015-09-08 18:42:29 +0800
commit652eea71febb8ae39cde9d72c1d4a74e193ec55e (patch)
tree92e011e70d5b8fbb66c28615b57f151c76b8dbbe
parent618065895b9ec3170eeb954bd12f8de58255e5c6 (diff)
downloadgo-tangerine-652eea71febb8ae39cde9d72c1d4a74e193ec55e.tar
go-tangerine-652eea71febb8ae39cde9d72c1d4a74e193ec55e.tar.gz
go-tangerine-652eea71febb8ae39cde9d72c1d4a74e193ec55e.tar.bz2
go-tangerine-652eea71febb8ae39cde9d72c1d4a74e193ec55e.tar.lz
go-tangerine-652eea71febb8ae39cde9d72c1d4a74e193ec55e.tar.xz
go-tangerine-652eea71febb8ae39cde9d72c1d4a74e193ec55e.tar.zst
go-tangerine-652eea71febb8ae39cde9d72c1d4a74e193ec55e.zip
put unlock after lock
-rw-r--r--miner/agent.go8
1 files changed, 3 insertions, 5 deletions
diff --git a/miner/agent.go b/miner/agent.go
index c3ea91b50..7ccf8d2e0 100644
--- a/miner/agent.go
+++ b/miner/agent.go
@@ -61,10 +61,10 @@ func (self *CpuAgent) Stop() {
}
func (self *CpuAgent) Start() {
- defer self.mu.Unlock()
self.mu.Lock()
-
- if atomic.LoadInt32(&self.isMining) == 1 {
+ defer self.mu.Unlock()
+
+ if !atomic.CompareAndSwapInt32(&self.isMining, 0, 1) {
return // agent already started
}
@@ -74,8 +74,6 @@ func (self *CpuAgent) Start() {
self.workCh = make(chan *Work, 1)
go self.update()
-
- atomic.StoreInt32(&self.isMining, 1)
}
func (self *CpuAgent) update() {