Lock the client when a non-parallel-safe function is called
Multiple Echo calls would overwrite themselfs. Lock the client to avoid this.
This commit is contained in:
parent
d40cb7e2b9
commit
06a017e098
@ -323,6 +323,11 @@ func (client *Client) Echo(data []byte) (echo []byte, err error) {
|
||||
}
|
||||
var mutex sync.Mutex
|
||||
mutex.Lock()
|
||||
|
||||
// Lock the client as only one echo may run parallel
|
||||
client.Lock()
|
||||
defer client.Unlock()
|
||||
|
||||
client.innerHandler.put("e", func(resp *Response) {
|
||||
echo = resp.Data
|
||||
mutex.Unlock()
|
||||
|
Loading…
Reference in New Issue
Block a user