Remove client locking from pool.go
client.go does do `client.Lock()` itself when it's needed. Doing the same in pool.go results in an dead lock.
This commit is contained in:
parent
81d00aa9ce
commit
d40cb7e2b9
@ -94,8 +94,6 @@ func (pool *Pool) Remove(addr string) {
|
|||||||
func (pool *Pool) Do(funcname string, data []byte,
|
func (pool *Pool) Do(funcname string, data []byte,
|
||||||
flag byte, h ResponseHandler) (addr, handle string, err error) {
|
flag byte, h ResponseHandler) (addr, handle string, err error) {
|
||||||
client := pool.selectServer()
|
client := pool.selectServer()
|
||||||
client.Lock()
|
|
||||||
defer client.Unlock()
|
|
||||||
handle, err = client.Do(funcname, data, flag, h)
|
handle, err = client.Do(funcname, data, flag, h)
|
||||||
addr = client.addr
|
addr = client.addr
|
||||||
return
|
return
|
||||||
@ -104,8 +102,6 @@ func (pool *Pool) Do(funcname string, data []byte,
|
|||||||
func (pool *Pool) DoBg(funcname string, data []byte,
|
func (pool *Pool) DoBg(funcname string, data []byte,
|
||||||
flag byte) (addr, handle string, err error) {
|
flag byte) (addr, handle string, err error) {
|
||||||
client := pool.selectServer()
|
client := pool.selectServer()
|
||||||
client.Lock()
|
|
||||||
defer client.Unlock()
|
|
||||||
handle, err = client.DoBg(funcname, data, flag)
|
handle, err = client.DoBg(funcname, data, flag)
|
||||||
addr = client.addr
|
addr = client.addr
|
||||||
return
|
return
|
||||||
@ -115,8 +111,6 @@ func (pool *Pool) DoBg(funcname string, data []byte,
|
|||||||
// !!!Not fully tested.!!!
|
// !!!Not fully tested.!!!
|
||||||
func (pool *Pool) Status(addr, handle string) (status *Status, err error) {
|
func (pool *Pool) Status(addr, handle string) (status *Status, err error) {
|
||||||
if client, ok := pool.Clients[addr]; ok {
|
if client, ok := pool.Clients[addr]; ok {
|
||||||
client.Lock()
|
|
||||||
defer client.Unlock()
|
|
||||||
status, err = client.Status(handle)
|
status, err = client.Status(handle)
|
||||||
} else {
|
} else {
|
||||||
err = ErrNotFound
|
err = ErrNotFound
|
||||||
@ -136,8 +130,6 @@ func (pool *Pool) Echo(addr string, data []byte) (echo []byte, err error) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
client.Lock()
|
|
||||||
defer client.Unlock()
|
|
||||||
echo, err = client.Echo(data)
|
echo, err = client.Echo(data)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user