Skip to content

net: fix deadlock in lookupProtocol on Windows #73364

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 2 additions & 5 deletions src/net/lookup_windows.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ func lookupProtocol(ctx context.Context, name string) (int, error) {
proto int
err error
}
ch := make(chan result) // unbuffered
ch := make(chan result, 1) // buffer so that next goroutine never blocks
go func() {
if err := acquireThread(ctx); err != nil {
ch <- result{err: mapErr(err)}
Expand All @@ -62,10 +62,7 @@ func lookupProtocol(ctx context.Context, name string) (int, error) {
runtime.LockOSThread()
defer runtime.UnlockOSThread()
proto, err := getprotobyname(name)
select {
case ch <- result{proto: proto, err: err}:
case <-ctx.Done():
}
ch <- result{proto: proto, err: err}
}()
select {
case r := <-ch:
Expand Down