Skip to content

Commit 19fe31c

Browse files
committed
jsonrpc2: change handlingMu to sync.RWMutex and remove defer
1 parent 3369f45 commit 19fe31c

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

jsonrpc2.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ type Conn struct {
3232
pending map[ID]chan *WireResponse
3333
pendingMu sync.Mutex // protects the pending map
3434
handling map[ID]*Request
35-
handlingMu sync.Mutex // protects the handling map
35+
handlingMu sync.RWMutex // protects the handling map
3636
logger *zap.Logger
3737
}
3838

@@ -245,12 +245,12 @@ func (c *Conn) setHandling(r *Request, active bool) {
245245
return
246246
}
247247
r.conn.handlingMu.Lock()
248-
defer r.conn.handlingMu.Unlock()
249248
if active {
250249
r.conn.handling[*r.ID] = r
251250
} else {
252251
delete(r.conn.handling, *r.ID)
253252
}
253+
r.conn.handlingMu.Unlock()
254254
}
255255

256256
// Run blocks until the connection is terminated, and returns any error that

0 commit comments

Comments
 (0)