Skip to content

Commit 7bed3c7

Browse files
moredureianlancetaylor
authored andcommitted
net: use Done rather than comparing with context.Background
Fixes #49023 Change-Id: I3de70f8a25f4ba8a0fb8bb96581371e33fde2f7a GitHub-Last-Rev: b7ec940 GitHub-Pull-Request: #49024 Reviewed-on: https://go-review.googlesource.com/c/go/+/356471 Reviewed-by: Ian Lance Taylor <iant@golang.org> Trust: Damien Neil <dneil@google.com>
1 parent c3c4a2b commit 7bed3c7

File tree

1 file changed

+2
-3
lines changed

1 file changed

+2
-3
lines changed

src/net/fd_unix.go

+2-3
Original file line numberDiff line numberDiff line change
@@ -91,12 +91,11 @@ func (fd *netFD) connect(ctx context.Context, la, ra syscall.Sockaddr) (rsa sysc
9191
}
9292

9393
// Start the "interrupter" goroutine, if this context might be canceled.
94-
// (The background context cannot)
9594
//
9695
// The interrupter goroutine waits for the context to be done and
9796
// interrupts the dial (by altering the fd's write deadline, which
9897
// wakes up waitWrite).
99-
if ctx != context.Background() {
98+
if ctxDone := ctx.Done(); ctxDone != nil {
10099
// Wait for the interrupter goroutine to exit before returning
101100
// from connect.
102101
done := make(chan struct{})
@@ -116,7 +115,7 @@ func (fd *netFD) connect(ctx context.Context, la, ra syscall.Sockaddr) (rsa sysc
116115
}()
117116
go func() {
118117
select {
119-
case <-ctx.Done():
118+
case <-ctxDone:
120119
// Force the runtime's poller to immediately give up
121120
// waiting for writability, unblocking waitWrite
122121
// below.

0 commit comments

Comments
 (0)