diff options
author | Dominick Meglio <dcm5151@esu.edu> | 2005-09-18 16:44:49 +0000 |
---|---|---|
committer | Dominick Meglio <dcm5151@esu.edu> | 2005-09-18 16:44:49 +0000 |
commit | 6afd5c16d3f7377d47ee3d9bb3237b636cfe2f35 (patch) | |
tree | 7ed1eb594f2bb960952d69586063567769b8f767 /ares_getnameinfo.c | |
parent | 8df407ed7d946341302de0e5493a9636743b60ae (diff) | |
download | c-ares-6afd5c16d3f7377d47ee3d9bb3237b636cfe2f35.tar.gz c-ares-6afd5c16d3f7377d47ee3d9bb3237b636cfe2f35.tar.bz2 c-ares-6afd5c16d3f7377d47ee3d9bb3237b636cfe2f35.zip |
Added constants that will be used by ares_getaddrinfo. Made ares_getnameinfo use the reentrant getservbyport (getservbyport_r) if it isavailable to ensure it works properly in a threaded environment
Diffstat (limited to 'ares_getnameinfo.c')
-rw-r--r-- | ares_getnameinfo.c | 27 |
1 files changed, 26 insertions, 1 deletions
diff --git a/ares_getnameinfo.c b/ares_getnameinfo.c index 23a5c79..e137fd3 100644 --- a/ares_getnameinfo.c +++ b/ares_getnameinfo.c @@ -256,7 +256,16 @@ static char *lookup_service(unsigned short port, int flags, char *buf) { struct servent *se; const char *proto; - +#if GETSERVBYPORT_R_ARGS == 6 + struct servent ret; + char buf[4096]; + int len = 4096; +#elif GETSERVBYPORT_R_ARGS == 5 + char buf[4096]; + int len = 4096; +#elif GETSERVBYPORT_R_ARGS == 4 + struct servent_data sed; +#endif if (flags & ARES_NI_UDP) proto = "udp"; else if (flags & ARES_NI_SCTP) @@ -265,7 +274,23 @@ static char *lookup_service(unsigned short port, int flags, char *buf) proto = "dccp"; else proto = "tcp"; +#ifdef HAVE_GETSERVBYPORT_R + #if GETSERVBYPORT_R_ARGS == 6 + if (getservbyport_r(port, proto, se, buf, len, &ret)) + se = NULL; + #elif GETSERVBYPORT_R_ARGS == 5 + se = getservbyport_r(port, proto, se, buf, len); + #elif GETSERVBYPORT_R_ARGS == 4 + if (getservbyport_r(port, proto, se, &sed) == -1) + se = NULL; + #else + /* Lets just hope the OS uses TLS! */ + se = getservbyport(port, proto); + #endif +#else + /* Lets just hope the OS uses TLS! */ se = getservbyport(port, proto); +#endif if (se && se->s_name) strcpy(buf, se->s_name); else |