We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see ourdocumentation.
There was an error while loading.Please reload this page.
1 parentc63f0c1 commit5a03e10Copy full SHA for 5a03e10
close.go
@@ -239,11 +239,11 @@ func (c *Conn) waitGoroutines() error {
239
}
240
241
c.closeReadMu.Lock()
242
-ctx:=c.closeReadCtx
+closeRead:=c.closeReadCtx!=nil
243
c.closeReadMu.Unlock()
244
-ifctx!=nil {
+ifcloseRead {
245
select {
246
-case<-ctx.Done():
+case<-c.closeReadDone:
247
case<-t.C:
248
returnerrors.New("failed to wait for close read goroutine to exit")
249
conn.go
@@ -57,10 +57,10 @@ type Conn struct {
57
timeoutLoopDonechanstruct{}
58
59
// Read state.
60
-readMu*mu
61
-readHeaderBuf[8]byte
62
-readControlBuf[maxControlPayload]byte
63
-msgReader*msgReader
+readMu*mu
+readHeaderBuf [8]byte
+readControlBuf [maxControlPayload]byte
+msgReader*msgReader
64
65
// Write state.
66
msgWriter*msgWriter
@@ -69,8 +69,9 @@ type Conn struct {
69
writeHeaderBuf [8]byte
70
writeHeaderheader
71
72
-closeReadMu sync.Mutex
73
-closeReadCtx context.Context
+closeReadMu sync.Mutex
+closeReadCtx context.Context
74
+closeReadDonechanstruct{}
75
76
closedchanstruct{}
77
closeMu sync.Mutex
mask_asm.go
@@ -3,7 +3,7 @@
3
package websocket
4
5
funcmask(b []byte,keyuint32)uint32 {
6
-// TODO: Will enable in v1.9.0.
+// TODO: Will enable in v1.9.0.
7
returnmaskGo(b,key)
8
iflen(b)>0 {
9
returnmaskAsm(&b[0],len(b),key)
read.go
@@ -71,9 +71,11 @@ func (c *Conn) CloseRead(ctx context.Context) context.Context {
ctx,cancel:=context.WithCancel(ctx)
c.closeReadCtx=ctx
+c.closeReadDone=make(chanstruct{})
gofunc() {
78
+deferclose(c.closeReadDone)
79
defercancel()
80
deferc.close()
81
_,_,err:=c.Reader(ctx)