mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-08-20 10:52:25 +00:00
swarm/pss: fix data races with on Pss.symKeyPool
This commit is contained in:
parent
2e2baf28ea
commit
68b44ccf77
2 changed files with 4 additions and 2 deletions
|
|
@ -206,7 +206,9 @@ func (ctl *HandshakeController) updateKeys(pubkeyid string, topic *Topic, in boo
|
||||||
limit: limit,
|
limit: limit,
|
||||||
}
|
}
|
||||||
*keystore = append(*keystore, storekey)
|
*keystore = append(*keystore, storekey)
|
||||||
|
ctl.pss.mx.Lock()
|
||||||
ctl.pss.symKeyPool[*storekey.symKeyID][*topic].protected = true
|
ctl.pss.symKeyPool[*storekey.symKeyID][*topic].protected = true
|
||||||
|
ctl.pss.mx.Unlock()
|
||||||
}
|
}
|
||||||
for i := 0; i < len(*keystore); i++ {
|
for i := 0; i < len(*keystore); i++ {
|
||||||
ctl.symKeyIndex[*(*keystore)[i].symKeyID] = &((*keystore)[i])
|
ctl.symKeyIndex[*(*keystore)[i].symKeyID] = &((*keystore)[i])
|
||||||
|
|
|
||||||
|
|
@ -210,6 +210,8 @@ func (ks *Pss) processAsym(envelope *whisper.Envelope) (*whisper.ReceivedMessage
|
||||||
// - it is not marked as protected
|
// - it is not marked as protected
|
||||||
// - it is not in the incoming decryption cache
|
// - it is not in the incoming decryption cache
|
||||||
func (ks *Pss) cleanKeys() (count int) {
|
func (ks *Pss) cleanKeys() (count int) {
|
||||||
|
ks.mx.Lock()
|
||||||
|
defer ks.mx.Unlock()
|
||||||
for keyid, peertopics := range ks.symKeyPool {
|
for keyid, peertopics := range ks.symKeyPool {
|
||||||
var expiredtopics []Topic
|
var expiredtopics []Topic
|
||||||
for topic, psp := range peertopics {
|
for topic, psp := range peertopics {
|
||||||
|
|
@ -229,10 +231,8 @@ func (ks *Pss) cleanKeys() (count int) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
for _, topic := range expiredtopics {
|
for _, topic := range expiredtopics {
|
||||||
ks.mx.Lock()
|
|
||||||
delete(ks.symKeyPool[keyid], topic)
|
delete(ks.symKeyPool[keyid], topic)
|
||||||
log.Trace("symkey cleanup deletion", "symkeyid", keyid, "topic", topic, "val", ks.symKeyPool[keyid])
|
log.Trace("symkey cleanup deletion", "symkeyid", keyid, "topic", topic, "val", ks.symKeyPool[keyid])
|
||||||
ks.mx.Unlock()
|
|
||||||
count++
|
count++
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue