Merge pull request #2563 from obscuren/rpcaddr-fix
eth: fixed double close of channel. Fixes #2555
This commit is contained in:
commit
72e60dea36
@ -66,6 +66,9 @@ func (mux *TypeMux) Subscribe(types ...interface{}) Subscription {
|
|||||||
mux.mutex.Lock()
|
mux.mutex.Lock()
|
||||||
defer mux.mutex.Unlock()
|
defer mux.mutex.Unlock()
|
||||||
if mux.stopped {
|
if mux.stopped {
|
||||||
|
// set the status to closed so that calling Unsubscribe after this
|
||||||
|
// call will short curuit
|
||||||
|
sub.closed = true
|
||||||
close(sub.postC)
|
close(sub.postC)
|
||||||
} else {
|
} else {
|
||||||
if mux.subm == nil {
|
if mux.subm == nil {
|
||||||
|
@ -25,6 +25,14 @@ import (
|
|||||||
|
|
||||||
type testEvent int
|
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) {
|
func TestSub(t *testing.T) {
|
||||||
mux := new(TypeMux)
|
mux := new(TypeMux)
|
||||||
defer mux.Stop()
|
defer mux.Stop()
|
||||||
|
Loading…
Reference in New Issue
Block a user