Skip to content

Commit 510eed5

Browse files
committed
Document bug with release of bufio read/writers for client
1 parent b39ca87 commit 510eed5

File tree

5 files changed

+7
-6
lines changed

5 files changed

+7
-6
lines changed

dial.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,14 @@ import (
55
"bytes"
66
"context"
77
"encoding/base64"
8-
"golang.org/x/xerrors"
98
"io"
109
"io/ioutil"
1110
"net/http"
1211
"net/url"
1312
"strings"
1413
"sync"
14+
15+
"golang.org/x/xerrors"
1516
)
1617

1718
// DialOptions represents the options available to pass to Dial.

go.sum

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,6 @@ golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGm
2828
golang.org/x/tools v0.0.0-20190311212946-11955173bddd/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs=
2929
golang.org/x/tools v0.0.0-20190429184909-35c670923e21 h1:Kjcw+D2LTzLmxOHrMK9uvYP/NigJ0EdwMgzt6EU+Ghs=
3030
golang.org/x/tools v0.0.0-20190429184909-35c670923e21/go.mod h1:RgjU9mgBXZiqYHBnxXauZ1Gv1EHHAz9KjViQ78xBX0Q=
31-
golang.org/x/xerrors v0.0.0-20190315151331-d61658bd2e18 h1:1AGvnywFL1aB5KLRxyLseWJI6aSYPo3oF7HSpXdWQdU=
32-
golang.org/x/xerrors v0.0.0-20190315151331-d61658bd2e18/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
3331
golang.org/x/xerrors v0.0.0-20190513163551-3ee3066db522 h1:bhOzK9QyoD0ogCnFro1m2mz41+Ib0oOhfJnBp5MR4K4=
3432
golang.org/x/xerrors v0.0.0-20190513163551-3ee3066db522/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
3533
mvdan.cc/sh v2.6.4+incompatible h1:eD6tDeh0pw+/TOTI1BBEryZ02rD2nMcFsgcvde7jffM=

websocket.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,7 @@ func (c *Conn) close(err error) {
8585
if c.client {
8686
go func() {
8787
<-c.readLoopDone
88+
// TODO this does not work if reader errors out.
8889
c.readDataLock <- struct{}{}
8990
c.writeFrameLock <- struct{}{}
9091

websocket_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -758,7 +758,7 @@ func benchConn(b *testing.B, echo, stream bool, size int) {
758758
b.Fatal(err)
759759
}
760760

761-
_, err = r.Read(nil)
761+
_, err = r.Read([]byte{0})
762762
if !xerrors.Is(err, io.EOF) {
763763
b.Fatalf("more data in reader than needed")
764764
}

wsjson/wsjson.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,10 @@ package wsjson
44
import (
55
"context"
66
"encoding/json"
7-
"golang.org/x/xerrors"
87
"io"
98

9+
"golang.org/x/xerrors"
10+
1011
"nhooyr.io/websocket"
1112
)
1213

@@ -46,7 +47,7 @@ func read(ctx context.Context, c *websocket.Conn, v interface{}) error {
4647
// we support concurrent reading.
4748
// So the Reader has to synchronize with Read somehow.
4849
// Maybe its best to bring back the old readLoop?
49-
_, err = r.Read(nil)
50+
_, err = r.Read([]byte{0})
5051
if !xerrors.Is(err, io.EOF) {
5152
return xerrors.Errorf("more data than needed in reader")
5253
}

0 commit comments

Comments
 (0)