1
0
mirror of https://github.com/golang/go synced 2024-11-18 03:54:50 -07:00

acquire thread in res_nsearch

This commit is contained in:
Mateusz Poliwczak 2022-12-01 10:18:44 +01:00
parent 78472603c6
commit 0660c9a989

View File

@ -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 // resSearch will make a call to the 'res_nsearch' routine in the C library
// and parse the output as a slice of DNS resources. // and parse the output as a slice of DNS resources.
func resSearch(ctx context.Context, hostname string, rtype, class int) ([]dnsmessage.Resource, error) { 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{}))) state := (*_C_struct___res_state)(_C_malloc(unsafe.Sizeof(_C_struct___res_state{})))
defer _C_free(unsafe.Pointer(state)) defer _C_free(unsafe.Pointer(state))
if err := _C_res_ninit(state); err != nil { if err := _C_res_ninit(state); err != nil {