Skip to content

Commit 652eea7

Browse files
author
Bas van Kervel
committed
put unlock after lock
1 parent 6180658 commit 652eea7

File tree

1 file changed

+3
-5
lines changed

1 file changed

+3
-5
lines changed

miner/agent.go

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -61,10 +61,10 @@ func (self *CpuAgent) Stop() {
6161
}
6262

6363
func (self *CpuAgent) Start() {
64-
defer self.mu.Unlock()
6564
self.mu.Lock()
66-
67-
if atomic.LoadInt32(&self.isMining) == 1 {
65+
defer self.mu.Unlock()
66+
67+
if !atomic.CompareAndSwapInt32(&self.isMining, 0, 1) {
6868
return // agent already started
6969
}
7070

@@ -74,8 +74,6 @@ func (self *CpuAgent) Start() {
7474
self.workCh = make(chan *Work, 1)
7575

7676
go self.update()
77-
78-
atomic.StoreInt32(&self.isMining, 1)
7977
}
8078

8179
func (self *CpuAgent) update() {

0 commit comments

Comments
 (0)