diff options
author | Jeffrey Wilcke <geffobscura@gmail.com> | 2015-11-21 02:23:55 +0800 |
---|---|---|
committer | Jeffrey Wilcke <geffobscura@gmail.com> | 2015-11-25 19:10:47 +0800 |
commit | 5f0a4416db4339176e31fab5f4b7b79f4e7cf20b (patch) | |
tree | 828d36e96530feb48f310a0acd07cef372f0dc27 /whisper/whisper_test.go | |
parent | 4c2933ad825aa11ce118abddfe6eeafc0422b2b6 (diff) | |
download | go-tangerine-5f0a4416db4339176e31fab5f4b7b79f4e7cf20b.tar go-tangerine-5f0a4416db4339176e31fab5f4b7b79f4e7cf20b.tar.gz go-tangerine-5f0a4416db4339176e31fab5f4b7b79f4e7cf20b.tar.bz2 go-tangerine-5f0a4416db4339176e31fab5f4b7b79f4e7cf20b.tar.lz go-tangerine-5f0a4416db4339176e31fab5f4b7b79f4e7cf20b.tar.xz go-tangerine-5f0a4416db4339176e31fab5f4b7b79f4e7cf20b.tar.zst go-tangerine-5f0a4416db4339176e31fab5f4b7b79f4e7cf20b.zip |
whisper: fixed broadcast race
Whisper's expire and broadcast loops happen in two separate go routines.
Whenever an envelope is being expired it's removed from the set of
envelopes and it looses all information about the envelope, including
the "known hash". After the envelope has been removed it can be
re-accepted by a broadcasting peer putting back the envelope in the set
of envelopes. Since the envelope broadcast loop is separate of the
expire loop expired messages may be broadcast to other peer, resulting
in messages **never** being dropped.
This PR includes an expire check before adding new messages to the set
of envelopes.
Diffstat (limited to 'whisper/whisper_test.go')
-rw-r--r-- | whisper/whisper_test.go | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/whisper/whisper_test.go b/whisper/whisper_test.go index 1a9a8667a..b83ce0fe7 100644 --- a/whisper/whisper_test.go +++ b/whisper/whisper_test.go @@ -207,4 +207,13 @@ func TestMessageExpiration(t *testing.T) { if found { t.Fatalf("message not expired from cache") } + + node.add(envelope) + node.poolMu.RLock() + _, found = node.messages[envelope.Hash()] + node.poolMu.RUnlock() + if found { + t.Fatalf("message was added to cache") + } + } |