File tree 4 files changed +13
-10
lines changed
4 files changed +13
-10
lines changed Original file line number Diff line number Diff line change @@ -239,11 +239,11 @@ func (c *Conn) waitGoroutines() error {
239
239
}
240
240
241
241
c .closeReadMu .Lock ()
242
- ctx := c .closeReadCtx
242
+ closeRead := c .closeReadCtx != nil
243
243
c .closeReadMu .Unlock ()
244
- if ctx != nil {
244
+ if closeRead {
245
245
select {
246
- case <- ctx . Done () :
246
+ case <- c . closeReadDone :
247
247
case <- t .C :
248
248
return errors .New ("failed to wait for close read goroutine to exit" )
249
249
}
Original file line number Diff line number Diff line change @@ -57,10 +57,10 @@ type Conn struct {
57
57
timeoutLoopDone chan struct {}
58
58
59
59
// Read state.
60
- readMu * mu
61
- readHeaderBuf [8 ]byte
62
- readControlBuf [maxControlPayload ]byte
63
- msgReader * msgReader
60
+ readMu * mu
61
+ readHeaderBuf [8 ]byte
62
+ readControlBuf [maxControlPayload ]byte
63
+ msgReader * msgReader
64
64
65
65
// Write state.
66
66
msgWriter * msgWriter
@@ -69,8 +69,9 @@ type Conn struct {
69
69
writeHeaderBuf [8 ]byte
70
70
writeHeader header
71
71
72
- closeReadMu sync.Mutex
73
- closeReadCtx context.Context
72
+ closeReadMu sync.Mutex
73
+ closeReadCtx context.Context
74
+ closeReadDone chan struct {}
74
75
75
76
closed chan struct {}
76
77
closeMu sync.Mutex
Original file line number Diff line number Diff line change 3
3
package websocket
4
4
5
5
func mask (b []byte , key uint32 ) uint32 {
6
- // TODO: Will enable in v1.9.0.
6
+ // TODO: Will enable in v1.9.0.
7
7
return maskGo (b , key )
8
8
if len (b ) > 0 {
9
9
return maskAsm (& b [0 ], len (b ), key )
Original file line number Diff line number Diff line change @@ -71,9 +71,11 @@ func (c *Conn) CloseRead(ctx context.Context) context.Context {
71
71
}
72
72
ctx , cancel := context .WithCancel (ctx )
73
73
c .closeReadCtx = ctx
74
+ c .closeReadDone = make (chan struct {})
74
75
c .closeReadMu .Unlock ()
75
76
76
77
go func () {
78
+ defer close (c .closeReadDone )
77
79
defer cancel ()
78
80
defer c .close ()
79
81
_ , _ , err := c .Reader (ctx )
You can’t perform that action at this time.
0 commit comments