summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authordarin%meer.net <devnull@localhost>2004-09-01 23:07:28 +0000
committerdarin%meer.net <devnull@localhost>2004-09-01 23:07:28 +0000
commitd9a86b69911aff0ba000a59070aa525d2073b1c9 (patch)
tree1612fc36fa17110c552442323c0fb9d9822f49a6
parentc672b2152e52c3b20ca560a730aec832f280d4a1 (diff)
downloadnspr-hg-d9a86b69911aff0ba000a59070aa525d2073b1c9.tar.gz
landing patches for bug 239358 "DNS: Reverse lookups are degrading performance" r=lorenzo sr=bryner a=chofmann,brendanTHUNDERBIRD_0_8_RELEASEFIREFOX_0_10_RELEASEFIREFOX_0_10_1_RELEASE
-rw-r--r--pr/include/prnetdb.h16
-rw-r--r--pr/src/misc/prnetdb.c17
2 files changed, 22 insertions, 11 deletions
diff --git a/pr/include/prnetdb.h b/pr/include/prnetdb.h
index a2456137..0fec9390 100644
--- a/pr/include/prnetdb.h
+++ b/pr/include/prnetdb.h
@@ -134,10 +134,11 @@ NSPR_API(PRStatus) PR_GetHostByName(
***********************************************************************/
-#define PR_AI_ALL 0x08
-#define PR_AI_V4MAPPED 0x10
-#define PR_AI_ADDRCONFIG 0x20
-#define PR_AI_DEFAULT (PR_AI_V4MAPPED | PR_AI_ADDRCONFIG)
+#define PR_AI_ALL 0x08
+#define PR_AI_V4MAPPED 0x10
+#define PR_AI_ADDRCONFIG 0x20
+#define PR_AI_NOCANONNAME 0x8000
+#define PR_AI_DEFAULT (PR_AI_V4MAPPED | PR_AI_ADDRCONFIG)
NSPR_API(PRStatus) PR_GetIPNodeByName(
const char *hostname,
@@ -393,8 +394,11 @@ NSPR_API(PRStatus) PR_GetProtoByNumber(
**
** INPUTS:
** char *hostname Character string defining the host name of interest
-** PRUint16 af Must be PR_AF_UNSPEC
-** PRIntn flags Must be PR_AI_ADDRCONFIG
+** PRUint16 af May be PR_AF_UNSPEC or PR_AF_INET.
+** PRIntn flags May be either PR_AI_ADDRCONFIG or
+** PR_AI_ADDRCONFIG | PR_AI_NOCANONNAME. Include
+** PR_AI_NOCANONNAME to suppress the determination of
+** the canonical name corresponding to hostname.
** RETURN:
** PRAddrInfo* Handle to a data structure containing the results
** of the host lookup. Use PR_EnumerateAddrInfo to
diff --git a/pr/src/misc/prnetdb.c b/pr/src/misc/prnetdb.c
index b26b7539..909374e5 100644
--- a/pr/src/misc/prnetdb.c
+++ b/pr/src/misc/prnetdb.c
@@ -2028,6 +2028,7 @@ _pr_find_getaddrinfo(void)
typedef struct PRAddrInfoFB {
char buf[PR_NETDB_BUF_SIZE];
PRHostEnt hostent;
+ PRBool has_cname;
} PRAddrInfoFB;
static PRAddrInfo *
@@ -2048,6 +2049,8 @@ pr_GetAddrInfoByNameFB(const char *hostname,
PR_Free(ai);
return NULL;
}
+ ai->has_cname = !(flags & PR_AI_NOCANONNAME);
+
return (PRAddrInfo *) ai;
}
@@ -2056,7 +2059,8 @@ PR_IMPLEMENT(PRAddrInfo *) PR_GetAddrInfoByName(const char *hostname,
PRIntn flags)
{
/* restrict input to supported values */
- if ((af != PR_AF_INET && af != PR_AF_UNSPEC) || flags != PR_AI_ADDRCONFIG) {
+ if ((af != PR_AF_INET && af != PR_AF_UNSPEC) ||
+ (flags & ~ PR_AI_NOCANONNAME) != PR_AI_ADDRCONFIG) {
PR_SetError(PR_INVALID_ARGUMENT_ERROR, 0);
return NULL;
}
@@ -2082,7 +2086,7 @@ PR_IMPLEMENT(PRAddrInfo *) PR_GetAddrInfoByName(const char *hostname,
*/
memset(&hints, 0, sizeof(hints));
- hints.ai_flags = AI_CANONNAME;
+ hints.ai_flags = (flags & PR_AI_NOCANONNAME) ? 0: AI_CANONNAME;
hints.ai_family = (af == PR_AF_INET) ? AF_INET : AF_UNSPEC;
/*
@@ -2169,11 +2173,14 @@ PR_IMPLEMENT(const char *) PR_GetCanonNameFromAddrInfo(const PRAddrInfo *ai)
{
#if defined(_PR_HAVE_GETADDRINFO)
#if defined(_PR_INET6_PROBE)
- if (!_pr_ipv6_is_present)
- return ((const PRAddrInfoFB *) ai)->hostent.h_name;
+ if (!_pr_ipv6_is_present) {
+ const PRAddrInfoFB *fb = (const PRAddrInfoFB *) ai;
+ return fb->has_cname ? fb->hostent.h_name : NULL;
+ }
#endif
return ((const PRADDRINFO *) ai)->ai_canonname;
#else
- return ((const PRAddrInfoFB *) ai)->hostent.h_name;
+ const PRAddrInfoFB *fb = (const PRAddrInfoFB *) ai;
+ return fb->has_cname ? fb->hostent.h_name : NULL;
#endif
}