From 0708b573bc38c1d393d2452cb97807dccda70b5f Mon Sep 17 00:00:00 2001 From: ucwong Date: Tue, 28 Apr 2020 16:53:08 +0800 Subject: [PATCH] event, whisper/whisperv6: use defer where possible (#20940) --- event/event.go | 2 +- whisper/whisperv6/whisper.go | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/event/event.go b/event/event.go index 920681540d..ce1b03d523 100644 --- a/event/event.go +++ b/event/event.go @@ -196,9 +196,9 @@ func (s *TypeMuxSubscription) closewait() { s.closed = true s.postMu.Lock() + defer s.postMu.Unlock() close(s.postC) s.postC = nil - s.postMu.Unlock() } func (s *TypeMuxSubscription) deliver(event *TypeMuxEvent) { diff --git a/whisper/whisperv6/whisper.go b/whisper/whisperv6/whisper.go index 377406b360..af513888d0 100644 --- a/whisper/whisperv6/whisper.go +++ b/whisper/whisperv6/whisper.go @@ -340,11 +340,11 @@ func (whisper *Whisper) getPeers() []*Peer { arr := make([]*Peer, len(whisper.peers)) i := 0 whisper.peerMu.Lock() + defer whisper.peerMu.Unlock() for p := range whisper.peers { arr[i] = p i++ } - whisper.peerMu.Unlock() return arr }