net: mention the cgo lookup thread limit in package docs

Change-Id: I25af66b4f9991f121c4b0b6722b07db04b19120c
This commit is contained in:
Mateusz Poliwczak 2023-11-07 19:16:36 +01:00
parent cf52e70997
commit 749449505c
1 changed files with 6 additions and 2 deletions

View File

@ -46,8 +46,8 @@ It can use a pure Go resolver that sends DNS requests directly to the servers
listed in /etc/resolv.conf, or it can use a cgo-based resolver that calls C
library routines such as getaddrinfo and getnameinfo.
By default the pure Go resolver is used, because a blocked DNS request consumes
only a goroutine, while a blocked C call consumes an operating system thread.
On Unix the pure Go resolver is preferred over the cgo resolver, because a blocked DNS
request consumes only a goroutine, while a blocked C call consumes an operating system thread.
When cgo is available, the cgo-based resolver is used instead under a variety of
conditions: on systems that do not let programs make direct DNS requests (OS X),
when the LOCALDOMAIN environment variable is present (even if empty),
@ -57,6 +57,10 @@ when /etc/resolv.conf or /etc/nsswitch.conf specify the use of features that the
Go resolver does not implement, and when the name being looked up ends in .local
or is an mDNS name.
On all systems (except Plan 9), when the cgo resolver is being used
this package implies a concurrent cgo lookup limit to prevent the system
from running out of system threads. Currently, it is limited to 500 concurrent lookups.
The resolver decision can be overridden by setting the netdns value of the
GODEBUG environment variable (see package runtime) to go or cgo, as in: