aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJeffrey Wilcke <jeffrey@ethereum.org>2016-05-13 02:50:40 +0800
committerJeffrey Wilcke <jeffrey@ethereum.org>2016-05-13 02:50:40 +0800
commit72e60dea36157ee34d8b082b5868d52ac9ae6bc3 (patch)
tree1a53b64b4188a41deb22034a5c7188f0bb3db3d2
parenta5ff487889e8efae58461e0967cd6ec49facf6e9 (diff)
parent7c1f74713e273d1e4f1982466eb6fd96e55e8c4d (diff)
downloaddexon-72e60dea36157ee34d8b082b5868d52ac9ae6bc3.tar
dexon-72e60dea36157ee34d8b082b5868d52ac9ae6bc3.tar.gz
dexon-72e60dea36157ee34d8b082b5868d52ac9ae6bc3.tar.bz2
dexon-72e60dea36157ee34d8b082b5868d52ac9ae6bc3.tar.lz
dexon-72e60dea36157ee34d8b082b5868d52ac9ae6bc3.tar.xz
dexon-72e60dea36157ee34d8b082b5868d52ac9ae6bc3.tar.zst
dexon-72e60dea36157ee34d8b082b5868d52ac9ae6bc3.zip
Merge pull request #2563 from obscuren/rpcaddr-fix
eth: fixed double close of channel. Fixes #2555
-rw-r--r--event/event.go3
-rw-r--r--event/event_test.go8
2 files changed, 11 insertions, 0 deletions
diff --git a/event/event.go b/event/event.go
index 57dd52baa..fd0bcfbd4 100644
--- a/event/event.go
+++ b/event/event.go
@@ -66,6 +66,9 @@ func (mux *TypeMux) Subscribe(types ...interface{}) Subscription {
mux.mutex.Lock()
defer mux.mutex.Unlock()
if mux.stopped {
+ // set the status to closed so that calling Unsubscribe after this
+ // call will short curuit
+ sub.closed = true
close(sub.postC)
} else {
if mux.subm == nil {
diff --git a/event/event_test.go b/event/event_test.go
index 323cfea49..394029301 100644
--- a/event/event_test.go
+++ b/event/event_test.go
@@ -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()