Skip to content

Commit 8e34fe9

Browse files
authored
Fix deadlock in p2pclient/unary_handlers.go (#9)
In case of `!ok` and the following `return`, `c.mhandlers` won't be released, and this will lead to a deadlock. One solution is to use `defer c.mhandlers.Unlock()`, however `c.mhandlers` does not seem to be useful here at all.
1 parent a84b0a7 commit 8e34fe9

1 file changed

Lines changed: 0 additions & 2 deletions

File tree

p2pclient/unary_handlers.go

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,6 @@ func (c *Client) run(r ggio.Reader, w ggio.Writer) {
5757
case *pb.PersistentConnectionResponse_RequestHandling:
5858
proto := protocol.ID(*resp.GetRequestHandling().Proto)
5959

60-
c.mhandlers.Lock()
6160
h, found := c.unaryHandlers.Load(proto)
6261
handler, ok := h.(UnaryHandlerFunc)
6362
if !ok {
@@ -68,7 +67,6 @@ func (c *Client) run(r ggio.Reader, w ggio.Writer) {
6867
if !found {
6968
w.WriteMsg(makeErrProtoNotFoundMsg(resp.CallId, string(proto)))
7069
}
71-
c.mhandlers.Unlock()
7270

7371
go func() {
7472
ctx, cancel := context.WithCancel(context.Background())

0 commit comments

Comments
 (0)