Use a mutex write-lock for a write operation

This commit is contained in:
obscuren
2015-02-15 02:12:14 +01:00
parent b143dad596
commit 09e53367a2
2 changed files with 8 additions and 8 deletions

View File

@ -436,15 +436,15 @@ func (self *BlacklistMap) Exists(pubkey []byte) (ok bool) {
}
func (self *BlacklistMap) Put(pubkey []byte) error {
self.lock.RLock()
defer self.lock.RUnlock()
self.lock.Lock()
defer self.lock.Unlock()
self.blacklist[string(pubkey)] = true
return nil
}
func (self *BlacklistMap) Delete(pubkey []byte) error {
self.lock.RLock()
defer self.lock.RUnlock()
self.lock.Lock()
defer self.lock.Unlock()
delete(self.blacklist, string(pubkey))
return nil
}