move mutex before select

This commit is contained in:
Anton Evangelatov 2020-07-20 10:15:01 +02:00
parent e1c9c4297b
commit 69ebd2bb85

View File

@ -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