File tree Expand file tree Collapse file tree 1 file changed +9
-0
lines changed Expand file tree Collapse file tree 1 file changed +9
-0
lines changed Original file line number Diff line number Diff line change @@ -217,6 +217,12 @@ func (c *Conn) readLoop(ctx context.Context) (header, error) {
217
217
}
218
218
}
219
219
220
+ // prepareRead sets the readTimeout context and returns a done function
221
+ // to be called after the read is done. It also returns an error if the
222
+ // connection is closed. The reference to the error is used to assign
223
+ // an error depending on if the connection closed or the context timed
224
+ // out during use. Typically the referenced error is a named return
225
+ // variable of the function calling this method.
220
226
func (c * Conn ) prepareRead (ctx context.Context , err * error ) (func (), error ) {
221
227
select {
222
228
case <- c .closed :
@@ -335,6 +341,9 @@ func (c *Conn) handleControl(ctx context.Context, h header) (err error) {
335
341
closeSent := c .closeSentErr != nil
336
342
c .closeStateMu .Unlock ()
337
343
344
+ // Only unlock readMu if this connection is being closed becaue
345
+ // c.close will try to acquire the readMu lock. We unlock for
346
+ // writeClose as well because it may also call c.close.
338
347
if ! closeSent {
339
348
c .readMu .unlock ()
340
349
_ = c .writeClose (ce .Code , ce .Reason )
You can’t perform that action at this time.
0 commit comments