Skip to content

Commit 2180a12

Browse files
committed
Fix deadlock in BidirectionalConn
1 parent 8d192ef commit 2180a12

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

bidirectional_conn.go

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -257,23 +257,25 @@ func (c *bidirectionalHandler) OnReadCompleted(stream BidirectionalStream, bytes
257257
return
258258
}
259259

260+
c.access.Unlock()
261+
260262
select {
261263
case <-c.close:
262264
case <-c.done:
263265
case c.read <- bytesRead:
264266
}
265-
266-
c.access.Unlock()
267267
}
268268

269269
func (c *bidirectionalHandler) OnWriteCompleted(stream BidirectionalStream) {
270270
c.access.Lock()
271-
defer c.access.Unlock()
272271

273272
if c.err != nil {
273+
c.access.Unlock()
274274
return
275275
}
276276

277+
c.access.Unlock()
278+
277279
select {
278280
case <-c.close:
279281
case <-c.done:

0 commit comments

Comments
 (0)