File tree Expand file tree Collapse file tree 4 files changed +13
-10
lines changed Expand file tree Collapse file tree 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 {
239239 }
240240
241241 c .closeReadMu .Lock ()
242- ctx := c .closeReadCtx
242+ closeRead := c .closeReadCtx != nil
243243 c .closeReadMu .Unlock ()
244- if ctx != nil {
244+ if closeRead {
245245 select {
246- case <- ctx . Done () :
246+ case <- c . closeReadDone :
247247 case <- t .C :
248248 return errors .New ("failed to wait for close read goroutine to exit" )
249249 }
Original file line number Diff line number Diff line change @@ -57,10 +57,10 @@ type Conn struct {
5757 timeoutLoopDone chan struct {}
5858
5959 // 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
6464
6565 // Write state.
6666 msgWriter * msgWriter
@@ -69,8 +69,9 @@ type Conn struct {
6969 writeHeaderBuf [8 ]byte
7070 writeHeader header
7171
72- closeReadMu sync.Mutex
73- closeReadCtx context.Context
72+ closeReadMu sync.Mutex
73+ closeReadCtx context.Context
74+ closeReadDone chan struct {}
7475
7576 closed chan struct {}
7677 closeMu sync.Mutex
Original file line number Diff line number Diff line change 33package websocket
44
55func mask (b []byte , key uint32 ) uint32 {
6- // TODO: Will enable in v1.9.0.
6+ // TODO: Will enable in v1.9.0.
77 return maskGo (b , key )
88 /*
99 if len(b) > 0 {
Original file line number Diff line number Diff line change @@ -71,9 +71,11 @@ func (c *Conn) CloseRead(ctx context.Context) context.Context {
7171 }
7272 ctx , cancel := context .WithCancel (ctx )
7373 c .closeReadCtx = ctx
74+ c .closeReadDone = make (chan struct {})
7475 c .closeReadMu .Unlock ()
7576
7677 go func () {
78+ defer close (c .closeReadDone )
7779 defer cancel ()
7880 defer c .close ()
7981 _ , _ , err := c .Reader (ctx )
You can’t perform that action at this time.
0 commit comments