Commit 09e53367 authored by obscuren's avatar obscuren

Use a mutex write-lock for a write operation

parent b143dad5
...@@ -436,15 +436,15 @@ func (self *BlacklistMap) Exists(pubkey []byte) (ok bool) { ...@@ -436,15 +436,15 @@ func (self *BlacklistMap) Exists(pubkey []byte) (ok bool) {
} }
func (self *BlacklistMap) Put(pubkey []byte) error { func (self *BlacklistMap) Put(pubkey []byte) error {
self.lock.RLock() self.lock.Lock()
defer self.lock.RUnlock() defer self.lock.Unlock()
self.blacklist[string(pubkey)] = true self.blacklist[string(pubkey)] = true
return nil return nil
} }
func (self *BlacklistMap) Delete(pubkey []byte) error { func (self *BlacklistMap) Delete(pubkey []byte) error {
self.lock.RLock() self.lock.Lock()
defer self.lock.RUnlock() defer self.lock.Unlock()
delete(self.blacklist, string(pubkey)) delete(self.blacklist, string(pubkey))
return nil return nil
} }
...@@ -109,8 +109,8 @@ func (self *EthereumApi) NewFilterString(args string, reply *interface{}) error ...@@ -109,8 +109,8 @@ func (self *EthereumApi) NewFilterString(args string, reply *interface{}) error
} }
func (self *EthereumApi) FilterChanged(id int, reply *interface{}) error { func (self *EthereumApi) FilterChanged(id int, reply *interface{}) error {
self.logMut.RLock() self.logMut.Lock()
defer self.logMut.RUnlock() defer self.logMut.Unlock()
*reply = toLogs(self.logs[id]) *reply = toLogs(self.logs[id])
...@@ -309,8 +309,8 @@ func (p *EthereumApi) NewWhisperFilter(args *xeth.Options, reply *interface{}) e ...@@ -309,8 +309,8 @@ func (p *EthereumApi) NewWhisperFilter(args *xeth.Options, reply *interface{}) e
} }
func (self *EthereumApi) MessagesChanged(id int, reply *interface{}) error { func (self *EthereumApi) MessagesChanged(id int, reply *interface{}) error {
self.messagesMut.RLock() self.messagesMut.Lock()
defer self.messagesMut.RUnlock() defer self.messagesMut.Unlock()
*reply = self.messages[id] *reply = self.messages[id]
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment