move mutex before select
This commit is contained in:
parent
e1c9c4297b
commit
69ebd2bb85
@ -91,12 +91,13 @@ func (m *Miner) Start(ctx context.Context) error {
|
|||||||
|
|
||||||
func (m *Miner) Stop(ctx context.Context) error {
|
func (m *Miner) Stop(ctx context.Context) error {
|
||||||
m.lk.Lock()
|
m.lk.Lock()
|
||||||
defer m.lk.Unlock()
|
|
||||||
|
|
||||||
m.stopping = make(chan struct{})
|
m.stopping = make(chan struct{})
|
||||||
stopping := m.stopping
|
stopping := m.stopping
|
||||||
close(m.stop)
|
close(m.stop)
|
||||||
|
|
||||||
|
m.lk.Unlock()
|
||||||
|
|
||||||
select {
|
select {
|
||||||
case <-stopping:
|
case <-stopping:
|
||||||
return nil
|
return nil
|
||||||
|
Loading…
Reference in New Issue
Block a user