Skip to content

Commit dd5bc96

Browse files
neildgopherbot
authored andcommitted
internal/quic: deflake TestConnTestConn
Sending a message to a connection returns an error when the connection event loop had exited. This is unreliable, since a sent to the conn's message channel can succeed after the event loop exits, writing the message to the channel buffer. Drop the error return from Conn.sendMsg; it isn't useful, since it's always possible for the connection to exit with messages still in the channel buffer. Fixes golang/go#61485 Change-Id: Ic8351f984df827af881cf7b6d93d97031d2e615c Reviewed-on: https://go-review.googlesource.com/c/net/+/511658 TryBot-Result: Gopher Robot <gobot@golang.org> Reviewed-by: Jonathan Amsterdam <jba@google.com> Auto-Submit: Damien Neil <dneil@google.com> Run-TryBot: Damien Neil <dneil@google.com>
1 parent d0912d4 commit dd5bc96

File tree

2 files changed

+4
-10
lines changed

2 files changed

+4
-10
lines changed

internal/quic/conn.go

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -176,24 +176,21 @@ func (c *Conn) loop(now time.Time) {
176176

177177
// sendMsg sends a message to the conn's loop.
178178
// It does not wait for the message to be processed.
179-
func (c *Conn) sendMsg(m any) error {
179+
// The conn may close before processing the message, in which case it is lost.
180+
func (c *Conn) sendMsg(m any) {
180181
select {
181182
case c.msgc <- m:
182183
case <-c.donec:
183-
return errors.New("quic: connection closed")
184184
}
185-
return nil
186185
}
187186

188187
// runOnLoop executes a function within the conn's loop goroutine.
189188
func (c *Conn) runOnLoop(f func(now time.Time, c *Conn)) error {
190189
donec := make(chan struct{})
191-
if err := c.sendMsg(func(now time.Time, c *Conn) {
190+
c.sendMsg(func(now time.Time, c *Conn) {
192191
defer close(donec)
193192
f(now, c)
194-
}); err != nil {
195-
return err
196-
}
193+
})
197194
select {
198195
case <-donec:
199196
case <-c.donec:

internal/quic/conn_test.go

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -43,9 +43,6 @@ func TestConnTestConn(t *testing.T) {
4343
tc.wait()
4444

4545
tc.advanceToTimer()
46-
if err := tc.conn.sendMsg(nil); err == nil {
47-
t.Errorf("after advancing to idle timeout, sendMsg = nil, want error")
48-
}
4946
if !tc.conn.exited {
5047
t.Errorf("after advancing to idle timeout, exited = false, want true")
5148
}

0 commit comments

Comments
 (0)