move acquireThread out of goroutine

Change-Id: I0cdb08bf59c7b7a549e873da5f6f22b309daa0e9
This commit is contained in:
Mateusz Poliwczak 2024-02-20 18:17:22 +01:00
parent 9c93066809
commit cfc47684a6
1 changed files with 9 additions and 10 deletions

View File

@ -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()