Skip to content

Commit 682a34b

Browse files
committed
Add additional context to disabling early-noise
1 parent 85549c0 commit 682a34b

File tree

1 file changed

+8
-7
lines changed

1 file changed

+8
-7
lines changed

tsserver/server.go

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -132,13 +132,11 @@ type memListen struct {
132132

133133
// Accept waits for and returns the next connection to the listener.
134134
func (m *memListen) Accept() (net.Conn, error) {
135-
select {
136-
case c := <-m.listen:
137-
if c == nil {
138-
return nil, errors.New("closed")
139-
}
140-
return c, nil
135+
c, ok := <-m.listen
136+
if !ok {
137+
return nil, errors.New("closed")
141138
}
139+
return c, nil
142140
}
143141

144142
// Close closes the listener.
@@ -258,7 +256,10 @@ func (s *server) NoiseUpgradeHandler(w http.ResponseWriter, r *http.Request) {
258256
// (such as our in-memory connection to the tsserver), the client will
259257
// just hang on https://github.com/coadler/tailscale/blob/main/internal/noiseconn/conn.go#L59
260258
// and https://github.com/coadler/tailscale/blob/main/control/controlhttp/server.go#L107.
261-
// Disabling the early write seems to fix it.
259+
// Disabling the early write seems to fix it. Using a buffered network
260+
// connection (such as *fasthttputil.InmemoryListener), works somewhat
261+
// but still causes random race conditions that causes the connection to
262+
// stall.
262263
nil,
263264
)
264265
if err != nil {

0 commit comments

Comments
 (0)