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
This commit is contained in:
parent
e7093b3ca8
commit
6a48639c68
@ -1,5 +1,12 @@
|
||||
Changelog for the c-ares project
|
||||
|
||||
* September 18
|
||||
|
||||
- Added constants that will be used by ares_getaddrinfo
|
||||
|
||||
- Made ares_getnameinfo use the reentrant getservbyport (getservbyport_r) if it is
|
||||
available to ensure it works properly in a threaded environment.
|
||||
|
||||
* September 10
|
||||
|
||||
- configure fix for detecting a member in the sockaddr_in6 struct which failed
|
||||
|
@ -269,3 +269,50 @@ AC_DEFUN([CARES_CHECK_CONSTANT], [
|
||||
])
|
||||
|
||||
|
||||
dnl This macro determines how many parameters getservbyport_r takes
|
||||
AC_DEFUN([CARES_CHECK_GETSERVBYPORT_R], [
|
||||
AC_MSG_CHECKING([how many arguments getservbyport_r takes])
|
||||
AC_TRY_COMPILE(
|
||||
[#include <netdb.h>],
|
||||
[
|
||||
int p1, p5;
|
||||
char *p2, p4[4096];
|
||||
struct servent *p3, *p6;
|
||||
getservbyport_r(p1, p2, p3, p4, p5, &p6);
|
||||
], ac_func_getservbyport_r=6,
|
||||
[AC_TRY_COMPILE(
|
||||
[#include <netdb.h>],
|
||||
[
|
||||
int p1, p5;
|
||||
char *p2, p4[4096];
|
||||
struct servent *p3;
|
||||
getservbyport_r(p1, p2, p3, p4, p5);
|
||||
], ac_func_getservbyport_r=5,
|
||||
[AC_TRY_COMPILE(
|
||||
[#include <netdb.h>],
|
||||
[
|
||||
int p1;
|
||||
char *p2;
|
||||
struct servent *p3;
|
||||
struct servent_data p4;
|
||||
getservbyport_r(p1, p2, p3, &p4);
|
||||
], ac_func_getservbyport_r=4, ac_func_getservbyport_r=0
|
||||
)]
|
||||
)]
|
||||
)
|
||||
if test $ac_func_getservbyport_r != "0" ; then
|
||||
AC_MSG_RESULT($ac_func_getservbyport_r)
|
||||
AC_DEFINE(HAVE_GETSERVBYPORT_R, 1, [Specifies whether getservbyport_r is present])
|
||||
AC_DEFINE_UNQUOTED(GETSERVBYPORT_R_ARGS, $ac_func_getservbyport_r, [Specifies the number of arguments to
|
||||
getservbyport_r])
|
||||
if test $ac_func_getservbyport_r = "4" ; then
|
||||
AC_DEFINE(GETSERVBYPORT_R_BUFSIZE, sizeof(struct servent_data), [Specifies the size of the buffer to pass to
|
||||
getservbyport_r])
|
||||
else
|
||||
AC_DEFINE(GETSERVBYPORT_R_BUFSIZE, 4096, [Specifies the size of the buffer to pass to getservbyport_r])
|
||||
fi
|
||||
else
|
||||
AC_MSG_RESULT([not found])
|
||||
fi
|
||||
])
|
||||
|
||||
|
26
ares/ares.h
26
ares/ares.h
@ -69,6 +69,10 @@ extern "C" {
|
||||
/* ares_getnameinfo error codes */
|
||||
#define ARES_EBADFLAGS 18
|
||||
|
||||
/* ares_getaddrinfo error codes */
|
||||
#define ARES_ENONAME 19
|
||||
#define ARES_EBADHINTS 20
|
||||
|
||||
/* Flag values */
|
||||
#define ARES_FLAG_USEVC (1 << 0)
|
||||
#define ARES_FLAG_PRIMARY (1 << 1)
|
||||
@ -105,8 +109,26 @@ extern "C" {
|
||||
#define ARES_NI_LOOKUPSERVICE (1 << 9)
|
||||
/* Reserved for future use */
|
||||
#define ARES_NI_IDN (1 << 10)
|
||||
#define ARES_NI_ALLOW_UNASSIGNED (1 << 11)
|
||||
#define ARES_NI_USE_STD3_ASCII_RULES (1 << 12)
|
||||
#define ARES_NI_IDN_ALLOW_UNASSIGNED (1 << 11)
|
||||
#define ARES_NI_IDN_USE_STD3_ASCII_RULES (1 << 12)
|
||||
|
||||
/* Addrinfo flag values */
|
||||
#define ARES_AI_CANONNAME (1 << 0)
|
||||
#define ARES_AI_NUMERICHOST (1 << 1)
|
||||
#define ARES_AI_PASSIVE (1 << 2)
|
||||
#define ARES_AI_NUMERICSERV (1 << 3)
|
||||
#define ARES_AI_V4MAPPED (1 << 4)
|
||||
#define ARES_AI_ALL (1 << 5)
|
||||
#define ARES_AI_ADDRCONFIG (1 << 6)
|
||||
/* Reserved for future use */
|
||||
#define ARES_AI_IDN (1 << 10)
|
||||
#define ARES_AI_IDN_ALLOW_UNASSIGNED (1 << 11)
|
||||
#define ARES_AI_IDN_USE_STD3_ASCII_RULES (1 << 12)
|
||||
#define ARES_AI_CANONIDN (1 << 13)
|
||||
|
||||
#define ARES_AI_MASK (ARES_AI_CANONNAME|ARES_AI_NUMERICHOST|ARES_AI_PASSIVE| \
|
||||
ARES_AI_NUMERICSERV|ARES_AI_V4MAPPED|ARES_AI_ALL| \
|
||||
ARES_AI_ADDRCONFIG)
|
||||
|
||||
struct ares_options {
|
||||
int flags;
|
||||
|
@ -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
|
||||
|
@ -347,6 +347,9 @@ AC_CHECK_SIZEOF(struct in_addr, ,
|
||||
|
||||
AC_CHECK_FUNCS([bitncmp if_indextoname])
|
||||
|
||||
dnl God bless non-standardized functions! We need to see which getservbyport_r variant is available
|
||||
CARES_CHECK_GETSERVBYPORT_R
|
||||
|
||||
CURL_CHECK_NONBLOCKING_SOCKET
|
||||
|
||||
AC_OUTPUT(Makefile)
|
||||
|
Loading…
Reference in New Issue
Block a user