From 0660c9a989600eeb8652d1228777488d28397731 Mon Sep 17 00:00:00 2001 From: Mateusz Poliwczak Date: Thu, 1 Dec 2022 10:18:44 +0100 Subject: [PATCH] acquire thread in res_nsearch --- src/net/cgo_unix.go | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/net/cgo_unix.go b/src/net/cgo_unix.go index b9759d05a3..92ef34ab6a 100644 --- a/src/net/cgo_unix.go +++ b/src/net/cgo_unix.go @@ -331,6 +331,9 @@ func cgoLookupCNAME(ctx context.Context, name string) (cname string, err error, // resSearch will make a call to the 'res_nsearch' routine in the C library // and parse the output as a slice of DNS resources. func resSearch(ctx context.Context, hostname string, rtype, class int) ([]dnsmessage.Resource, error) { + acquireThread() + defer releaseThread() + state := (*_C_struct___res_state)(_C_malloc(unsafe.Sizeof(_C_struct___res_state{}))) defer _C_free(unsafe.Pointer(state)) if err := _C_res_ninit(state); err != nil {