mirror of
https://gitlab.com/pulsechaincom/erigon-pulse.git
synced 2024-12-22 03:30:37 +00:00
event: fix inconsistency in Lock and Unlock (#20933)
Co-authored-by: Felix Lange <fjl@twurst.com>
This commit is contained in:
parent
93840b6c72
commit
b70eaf8a21
@ -102,6 +102,7 @@ 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()
|
||||
@ -109,11 +110,11 @@ func (mux *TypeMux) Stop() {
|
||||
}
|
||||
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 {
|
||||
@ -123,7 +124,6 @@ func (mux *TypeMux) del(s *TypeMuxSubscription) {
|
||||
}
|
||||
}
|
||||
}
|
||||
s.mux.mutex.Unlock()
|
||||
}
|
||||
|
||||
func find(slice []*TypeMuxSubscription, item *TypeMuxSubscription) int {
|
||||
|
Loading…
Reference in New Issue
Block a user