Skip to content

Commit

Permalink
nwrap: Add BSD libc support for gethost*_r functios.
Browse files Browse the repository at this point in the history
BSD libc stores data in thread local storage.

Signed-off-by: Robin Hack <[email protected]>
Reviewed-by: Andreas Schneider <[email protected]>
Reviewed-by: Michael Adam <[email protected]>
  • Loading branch information
marmolak authored and obnoxxx committed Jan 11, 2016
1 parent 960345e commit 1017031
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions lib/nss_wrapper/nss_wrapper.c
Original file line number Diff line number Diff line change
Expand Up @@ -4746,8 +4746,14 @@ void endhostent(void)
}
#endif /* HAVE_SOLARIS_ENDHOSTENT */

#ifdef BSD
/* BSD implementation stores data in thread local storage but GLIBC does not */
static __thread struct hostent user_he;
static __thread struct nwrap_vector user_addrlist;
#else
static struct hostent user_he;
static struct nwrap_vector user_addrlist;
#endif /* BSD */
static struct hostent *nwrap_gethostbyname(const char *name)
{
if (nwrap_files_gethostbyname(name, AF_UNSPEC, &user_he, &user_addrlist) == -1) {
Expand All @@ -4765,9 +4771,16 @@ struct hostent *gethostbyname(const char *name)
return nwrap_gethostbyname(name);
}

/* This is a GNU extension - Also can be found on BSD systems */
#ifdef HAVE_GETHOSTBYNAME2
#ifdef BSD
/* BSD implementation stores data in thread local storage but GLIBC not */
static __thread struct hostent user_he2;
static __thread struct nwrap_vector user_addrlist2;
#else
static struct hostent user_he2;
static struct nwrap_vector user_addrlist2;
#endif /* BSD */
static struct hostent *nwrap_gethostbyname2(const char *name, int af)
{
if (nwrap_files_gethostbyname(name, af, &user_he2, &user_addrlist2) == -1) {
Expand Down

0 comments on commit 1017031

Please sign in to comment.