Skip to content

Commit

Permalink
event: fix inconsistency in Lock and Unlock (ethereum#20933)
Browse files Browse the repository at this point in the history
Co-authored-by: Felix Lange <fjl@twurst.com>
  • Loading branch information
BurtonQin and fjl authored Apr 17, 2020
1 parent 7a63faf commit ca22d07
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions event/event.go
Original file line number Diff line number Diff line change
Expand Up @@ -104,18 +104,19 @@ func (mux *TypeMux) Post(ev interface{}) error {
// Stop blocks until all current deliveries have finished.
func (mux *TypeMux) Stop() {
mux.mutex.Lock()
defer mux.mutex.Unlock()
for _, subs := range mux.subm {
for _, sub := range subs {
sub.closewait()
}
}
mux.subm = nil
mux.stopped = true
mux.mutex.Unlock()
}

func (mux *TypeMux) del(s *TypeMuxSubscription) {
mux.mutex.Lock()
defer mux.mutex.Unlock()
for typ, subs := range mux.subm {
if pos := find(subs, s); pos >= 0 {
if len(subs) == 1 {
Expand All @@ -125,7 +126,6 @@ func (mux *TypeMux) del(s *TypeMuxSubscription) {
}
}
}
s.mux.mutex.Unlock()
}

func find(slice []*TypeMuxSubscription, item *TypeMuxSubscription) int {
Expand Down

0 comments on commit ca22d07

Please sign in to comment.