diff options
author | green <green@FreeBSD.org> | 2004-02-25 21:03:46 +0000 |
---|---|---|
committer | green <green@FreeBSD.org> | 2004-02-25 21:03:46 +0000 |
commit | 40452493ee2a89d18609e7a71f114981ff6a315a (patch) | |
tree | 9638e0bc7f96f243bb180d862cc5f1093a53454c /include | |
parent | 821b77eba39a417a7e8283015b0d7dcf52875715 (diff) | |
download | FreeBSD-src-40452493ee2a89d18609e7a71f114981ff6a315a.zip FreeBSD-src-40452493ee2a89d18609e7a71f114981ff6a315a.tar.gz |
Make the resolver(3) and many associated interfaces much more reentrant.
The getaddrinfo(3), getipnodebyname(3) and resolver(3) can coincide now
with what should be totally reentrant, and h_errno values will now
be preserved correctly, but this does not affect interfaces such as
gethostbyname(3) which are still mostly non-reentrant.
In all of these relevant functions, the thread-safety has been pushed
down as far as it seems possible right now. This means that operations
that are selected via nsdispatch(3) (i.e. files, yp, dns) are protected
still under global locks that getaddrinfo(3) defines, but where possible
the locking is greatly reduced. The most noticeable improvement is
that multiple DNS lookups can now be run at the same time, and this
shows major improvement in performance of DNS-lookup threaded programs,
and solves the "Mozilla tab serialization" problem.
No single-threaded applications need to be recompiled. Multi-threaded
applications that reference "_res" to change resolver(3) options will
need to be recompiled, and ones which reference "h_errno" will also
if they desire the correct h_errno values. If the applications already
understood that _res and h_errno were not thread-safe and had their own
locking, they will see no performance improvement but will not
actually break in any way.
Please note that when NSS modules are used, or when nsdispatch(3)
defaults to adding any lookups of its own to the individual libc
_nsdispatch() calls, those MUST be reentrant as well.
Diffstat (limited to 'include')
-rw-r--r-- | include/netdb.h | 5 | ||||
-rw-r--r-- | include/resolv.h | 7 |
2 files changed, 9 insertions, 3 deletions
diff --git a/include/netdb.h b/include/netdb.h index 0fa4d16..ba3ed32 100644 --- a/include/netdb.h +++ b/include/netdb.h @@ -82,7 +82,7 @@ typedef __socklen_t socklen_t; #define _PATH_PROTOCOLS "/etc/protocols" #define _PATH_SERVICES "/etc/services" -extern int h_errno; +#define h_errno (*__h_error()) /* * Structures returned by network data base library. All addresses are @@ -135,7 +135,7 @@ struct addrinfo { /* * Error return codes from gethostbyname() and gethostbyaddr() - * (left in extern int h_errno). + * (left in h_errno). */ #define NETDB_INTERNAL -1 /* see errno */ @@ -254,6 +254,7 @@ void setservent(int); */ /* DO NOT USE THESE, THEY ARE SUBJECT TO CHANGE AND ARE NOT PORTABLE!!! */ +int * __h_error(void); void _sethosthtent(int); void _endhosthtent(void); void _sethostdnsent(int); diff --git a/include/resolv.h b/include/resolv.h index 9305023..942d2d6 100644 --- a/include/resolv.h +++ b/include/resolv.h @@ -200,7 +200,12 @@ struct res_sym { char * humanname; /* Its fun name, like "mail exchanger" */ }; -extern struct __res_state _res; +__BEGIN_DECLS +extern struct __res_state *___res(void); +extern struct __res_state_ext *___res_ext(void); +__END_DECLS +#define _res (*___res()) +#define _res_ext (*___res_ext()) /* for INET6 */ extern struct __res_state_ext _res_ext; |