event: fixed subscribtions to stopped event mux
This fixes an issue where the following would lead to a panic due to a channel being closed twice: * Start mux * Stop mux * Sub to mux * Unsub This is fixed by setting the subscriptions status to closed resulting in the Unsubscribe to ignore the request when called.
This commit is contained in:
@ -25,6 +25,14 @@ import (
|
||||
|
||||
type testEvent int
|
||||
|
||||
func TestSubCloseUnsub(t *testing.T) {
|
||||
// the point of this test is **not** to panic
|
||||
var mux TypeMux
|
||||
mux.Stop()
|
||||
sub := mux.Subscribe(int(0))
|
||||
sub.Unsubscribe()
|
||||
}
|
||||
|
||||
func TestSub(t *testing.T) {
|
||||
mux := new(TypeMux)
|
||||
defer mux.Stop()
|
||||
|
Reference in New Issue
Block a user