You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
consider two routine,A call AddListenerForEvent and B call RemoveListener simultaneous.
B -> listener.SetRemoved()
A -> eventCell.AddListener(listenerID, cb)
A -> listener.AddEvent(event)
B -> for _, event := range listener.GetEvents() {
evsw.RemoveListenerForEvent(event, listenerID)
}
At this time, Listener added by A will not be clean up. the fix is to try AddEvent first, only when AddEvent succeeded, eventCell can AddListener.
by the way,eventCell.FireEvent is easy to deadlock, as lock's range is uncontrollable when run callback.
This issue doesn't exist in the current runtime, but as an base lib, I think it's better to more robust.
Lib event designed for multi routine, but AddListenerForEvent and RemoveListener manipulate listener and eventCell in different order.
tendermint/libs/events/events.go
Lines 76 to 78 in 0c9c329
tendermint/libs/events/events.go
Lines 94 to 98 in 0c9c329
consider two routine,A call AddListenerForEvent and B call RemoveListener simultaneous.
At this time, Listener added by A will not be clean up. the fix is to try AddEvent first, only when AddEvent succeeded, eventCell can AddListener.
by the way,eventCell.FireEvent is easy to deadlock, as lock's range is uncontrollable when run callback.
tendermint/libs/events/events.go
Lines 169 to 175 in 0c9c329
The text was updated successfully, but these errors were encountered: