mirror of https://github.com/golang/go.git
move acquireThread out of goroutine
Change-Id: I0cdb08bf59c7b7a549e873da5f6f22b309daa0e9
This commit is contained in:
parent
9c93066809
commit
cfc47684a6
|
|
@ -56,18 +56,17 @@ func doBlockingWithCtx[T any](ctx context.Context, lookupName string, blocking f
|
|||
err error
|
||||
}
|
||||
|
||||
if err := acquireThread(ctx); err != nil {
|
||||
var zero T
|
||||
return zero, &DNSError{
|
||||
Name: lookupName,
|
||||
Err: mapErr(err).Error(),
|
||||
IsTimeout: err == context.DeadlineExceeded,
|
||||
}
|
||||
}
|
||||
|
||||
res := make(chan result, 1)
|
||||
go func() {
|
||||
if err := acquireThread(ctx); err != nil {
|
||||
res <- result{
|
||||
err: &DNSError{
|
||||
Name: lookupName,
|
||||
Err: mapErr(err).Error(),
|
||||
IsTimeout: err == context.DeadlineExceeded,
|
||||
},
|
||||
}
|
||||
return
|
||||
}
|
||||
defer releaseThread()
|
||||
var r result
|
||||
r.res, r.err = blocking()
|
||||
|
|
|
|||
Loading…
Reference in New Issue