aboutsummaryrefslogtreecommitdiffstats
path: root/xeth/xeth.go
diff options
context:
space:
mode:
authorPéter Szilágyi <peterke@gmail.com>2015-04-20 19:56:38 +0800
committerPéter Szilágyi <peterke@gmail.com>2015-04-28 15:47:35 +0800
commit7948cc0029db76557d6540341bdfeb818ce32c65 (patch)
treed4547188632e4f53878cc0d06d1e4da840f35b07 /xeth/xeth.go
parent5aa523e32bedd923c4075a21daefd1b4a512277c (diff)
downloaddexon-7948cc0029db76557d6540341bdfeb818ce32c65.tar
dexon-7948cc0029db76557d6540341bdfeb818ce32c65.tar.gz
dexon-7948cc0029db76557d6540341bdfeb818ce32c65.tar.bz2
dexon-7948cc0029db76557d6540341bdfeb818ce32c65.tar.lz
dexon-7948cc0029db76557d6540341bdfeb818ce32c65.tar.xz
dexon-7948cc0029db76557d6540341bdfeb818ce32c65.tar.zst
dexon-7948cc0029db76557d6540341bdfeb818ce32c65.zip
rpc, whisper, xeth: fix RPC message retrieval data race
Diffstat (limited to 'xeth/xeth.go')
-rw-r--r--xeth/xeth.go13
1 files changed, 11 insertions, 2 deletions
diff --git a/xeth/xeth.go b/xeth/xeth.go
index e7e553036..8cc32c958 100644
--- a/xeth/xeth.go
+++ b/xeth/xeth.go
@@ -97,7 +97,7 @@ done:
}
for id, filter := range self.messages {
- if time.Since(filter.timeout) > filterTickerTime {
+ if time.Since(filter.activity()) > filterTickerTime {
self.Whisper().Unwatch(id)
delete(self.messages, id)
}
@@ -461,7 +461,7 @@ func (p *XEth) NewWhisperFilter(to, from string, topics []string) int {
p.messages[id].insert(msg)
}
id = p.Whisper().Watch(to, from, topics, callback)
- p.messages[id] = &whisperFilter{timeout: time.Now()}
+ p.messages[id] = newWhisperFilter(id, p.Whisper())
return id
}
@@ -481,7 +481,16 @@ func (self *XEth) MessagesChanged(id int) []WhisperMessage {
if self.messages[id] != nil {
return self.messages[id].retrieve()
}
+ return nil
+}
+
+func (self *XEth) Messages(id int) []WhisperMessage {
+ self.messagesMut.Lock()
+ defer self.messagesMut.Unlock()
+ if self.messages[id] != nil {
+ return self.messages[id].messages()
+ }
return nil
}