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>
diff --git a/internal/quic/conn.go b/internal/quic/conn.go
index cdf79d6..e6375e8 100644
--- a/internal/quic/conn.go
+++ b/internal/quic/conn.go
@@ -176,24 +176,21 @@
 
 // sendMsg sends a message to the conn's loop.
 // It does not wait for the message to be processed.
-func (c *Conn) sendMsg(m any) error {
+// The conn may close before processing the message, in which case it is lost.
+func (c *Conn) sendMsg(m any) {
 	select {
 	case c.msgc <- m:
 	case <-c.donec:
-		return errors.New("quic: connection closed")
 	}
-	return nil
 }
 
 // runOnLoop executes a function within the conn's loop goroutine.
 func (c *Conn) runOnLoop(f func(now time.Time, c *Conn)) error {
 	donec := make(chan struct{})
-	if err := c.sendMsg(func(now time.Time, c *Conn) {
+	c.sendMsg(func(now time.Time, c *Conn) {
 		defer close(donec)
 		f(now, c)
-	}); err != nil {
-		return err
-	}
+	})
 	select {
 	case <-donec:
 	case <-c.donec:
diff --git a/internal/quic/conn_test.go b/internal/quic/conn_test.go
index 6bb12e2..fda1d4b 100644
--- a/internal/quic/conn_test.go
+++ b/internal/quic/conn_test.go
@@ -43,9 +43,6 @@
 	tc.wait()
 
 	tc.advanceToTimer()
-	if err := tc.conn.sendMsg(nil); err == nil {
-		t.Errorf("after advancing to idle timeout, sendMsg = nil, want error")
-	}
 	if !tc.conn.exited {
 		t.Errorf("after advancing to idle timeout, exited = false, want true")
 	}