Skip to content

Commit 0708b57

Browse files
authored
event, whisper/whisperv6: use defer where possible (#20940)
1 parent 9887edd commit 0708b57

File tree

2 files changed

+2
-2
lines changed

2 files changed

+2
-2
lines changed

event/event.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -196,9 +196,9 @@ func (s *TypeMuxSubscription) closewait() {
196196
s.closed = true
197197

198198
s.postMu.Lock()
199+
defer s.postMu.Unlock()
199200
close(s.postC)
200201
s.postC = nil
201-
s.postMu.Unlock()
202202
}
203203

204204
func (s *TypeMuxSubscription) deliver(event *TypeMuxEvent) {

whisper/whisperv6/whisper.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -340,11 +340,11 @@ func (whisper *Whisper) getPeers() []*Peer {
340340
arr := make([]*Peer, len(whisper.peers))
341341
i := 0
342342
whisper.peerMu.Lock()
343+
defer whisper.peerMu.Unlock()
343344
for p := range whisper.peers {
344345
arr[i] = p
345346
i++
346347
}
347-
whisper.peerMu.Unlock()
348348
return arr
349349
}
350350

0 commit comments

Comments
 (0)