Bug 396509: call _pr_init_ipv6 lazily rather than during NSPR
initialization because _pr_init_ipv6 creates a test socket, and we can't create a socket during DLL initialization in a Windows Vista "Standard" Account with Parental Controls turned on. The patch is contributed by Jim Mathies <jmathies@mozilla.com>. r=wtc Modified files: prinit.c prnetdb.c pripv6.c prsocket.c ptio.c git-svn-id: svn://10.0.0.236/trunk@242977 18797224-902f-48f8-a5cc-f745e15eee43
This commit is contained in:
parent
3f62bb6b74
commit
d9cbf1b68d
@ -278,7 +278,7 @@ static PRInt32 PR_CALLBACK Ipv6ToIpv4SocketRecvFrom(PRFileDesc *fd, void *buf,
|
||||
}
|
||||
|
||||
#if defined(_PR_INET6_PROBE)
|
||||
PRBool _pr_ipv6_is_present;
|
||||
static PRBool ipv6_is_present;
|
||||
extern PRBool _pr_test_ipv6_socket(void);
|
||||
|
||||
#if !defined(_PR_INET6) && defined(_PR_HAVE_GETIPNODEBYNAME)
|
||||
@ -306,13 +306,15 @@ _pr_probe_ipv6_presence(void)
|
||||
}
|
||||
#endif /* _PR_INET6_PROBE */
|
||||
|
||||
PRStatus _pr_init_ipv6()
|
||||
static PRCallOnceType _pr_init_ipv6_once;
|
||||
|
||||
static PRStatus PR_CALLBACK _pr_init_ipv6(void)
|
||||
{
|
||||
const PRIOMethods *stubMethods;
|
||||
|
||||
#if defined(_PR_INET6_PROBE)
|
||||
_pr_ipv6_is_present = _pr_probe_ipv6_presence();
|
||||
if (PR_TRUE == _pr_ipv6_is_present)
|
||||
ipv6_is_present = _pr_probe_ipv6_presence();
|
||||
if (ipv6_is_present)
|
||||
return PR_SUCCESS;
|
||||
#endif
|
||||
|
||||
@ -348,10 +350,22 @@ PRStatus _pr_init_ipv6()
|
||||
return PR_SUCCESS;
|
||||
}
|
||||
|
||||
#if defined(_PR_INET6_PROBE)
|
||||
PRBool _pr_ipv6_is_present(void)
|
||||
{
|
||||
if (PR_CallOnce(&_pr_init_ipv6_once, _pr_init_ipv6) != PR_SUCCESS)
|
||||
return PR_FALSE;
|
||||
return ipv6_is_present;
|
||||
}
|
||||
#endif
|
||||
|
||||
PR_IMPLEMENT(PRStatus) _pr_push_ipv6toipv4_layer(PRFileDesc *fd)
|
||||
{
|
||||
PRFileDesc *ipv6_fd = NULL;
|
||||
|
||||
if (PR_CallOnce(&_pr_init_ipv6_once, _pr_init_ipv6) != PR_SUCCESS)
|
||||
return PR_FAILURE;
|
||||
|
||||
/*
|
||||
* For platforms with no support for IPv6
|
||||
* create layered socket for IPv4-mapped IPv6 addresses
|
||||
|
||||
@ -1267,7 +1267,7 @@ PR_EXTERN(PRStatus) _pr_push_ipv6toipv4_layer(PRFileDesc *fd);
|
||||
|
||||
#if defined(_PR_INET6_PROBE)
|
||||
|
||||
PR_EXTERN(PRBool) _pr_ipv6_is_present;
|
||||
extern PRBool _pr_ipv6_is_present(void);
|
||||
|
||||
PR_IMPLEMENT(PRBool) _pr_test_ipv6_socket()
|
||||
{
|
||||
@ -1302,12 +1302,8 @@ PR_IMPLEMENT(PRFileDesc*) PR_Socket(PRInt32 domain, PRInt32 type, PRInt32 proto)
|
||||
}
|
||||
|
||||
#if defined(_PR_INET6_PROBE)
|
||||
if (PR_AF_INET6 == domain) {
|
||||
if (_pr_ipv6_is_present == PR_FALSE)
|
||||
domain = AF_INET;
|
||||
else
|
||||
domain = AF_INET6;
|
||||
}
|
||||
if (PR_AF_INET6 == domain)
|
||||
domain = _pr_ipv6_is_present() ? AF_INET6 : AF_INET;
|
||||
#elif defined(_PR_INET6)
|
||||
if (PR_AF_INET6 == domain)
|
||||
domain = AF_INET6;
|
||||
|
||||
@ -163,10 +163,6 @@ static void _pr_SetNativeThreadsOnlyMode(void)
|
||||
}
|
||||
#endif
|
||||
|
||||
#if !defined(_PR_INET6) || defined(_PR_INET6_PROBE)
|
||||
extern PRStatus _pr_init_ipv6(void);
|
||||
#endif
|
||||
|
||||
static void _PR_InitStuff(void)
|
||||
{
|
||||
|
||||
@ -247,10 +243,6 @@ static void _PR_InitStuff(void)
|
||||
|
||||
nspr_InitializePRErrorTable();
|
||||
|
||||
#if !defined(_PR_INET6) || defined(_PR_INET6_PROBE)
|
||||
_pr_init_ipv6();
|
||||
#endif
|
||||
|
||||
_PR_MD_FINAL_INIT();
|
||||
}
|
||||
|
||||
|
||||
@ -125,7 +125,7 @@ PRLock* _getproto_lock = NULL;
|
||||
#endif
|
||||
|
||||
#if defined(_PR_INET6_PROBE)
|
||||
PR_EXTERN(PRBool) _pr_ipv6_is_present;
|
||||
extern PRBool _pr_ipv6_is_present(void);
|
||||
#endif
|
||||
|
||||
#define _PR_IN6_IS_ADDR_UNSPECIFIED(a) \
|
||||
@ -894,7 +894,7 @@ PR_IMPLEMENT(PRStatus) PR_GetIPNodeByName(
|
||||
if ((flags & PR_AI_ADDRCONFIG) == 0 || _pr_have_inet6_if)
|
||||
{
|
||||
#ifdef _PR_INET6_PROBE
|
||||
if (_pr_ipv6_is_present == PR_TRUE)
|
||||
if (_pr_ipv6_is_present())
|
||||
#endif
|
||||
h = GETHOSTBYNAME2(name, AF_INET6);
|
||||
}
|
||||
@ -919,7 +919,7 @@ PR_IMPLEMENT(PRStatus) PR_GetIPNodeByName(
|
||||
#error "Unknown name-to-address translation function"
|
||||
#endif /* _PR_HAVE_GETHOSTBYNAME2 */
|
||||
#elif defined(_PR_INET6_PROBE) && defined(_PR_HAVE_GETIPNODEBYNAME)
|
||||
if (_pr_ipv6_is_present == PR_TRUE)
|
||||
if (_pr_ipv6_is_present())
|
||||
{
|
||||
#ifdef PR_GETIPNODE_NOT_THREADSAFE
|
||||
LOCK_DNS();
|
||||
@ -945,7 +945,7 @@ PR_IMPLEMENT(PRStatus) PR_GetIPNodeByName(
|
||||
#if defined(_PR_INET6) && defined(_PR_HAVE_GETIPNODEBYNAME)
|
||||
PR_SetError(PR_DIRECTORY_LOOKUP_ERROR, error_num);
|
||||
#elif defined(_PR_INET6_PROBE) && defined(_PR_HAVE_GETIPNODEBYNAME)
|
||||
if (_pr_ipv6_is_present == PR_TRUE)
|
||||
if (_pr_ipv6_is_present())
|
||||
PR_SetError(PR_DIRECTORY_LOOKUP_ERROR, error_num);
|
||||
else
|
||||
PR_SetError(PR_DIRECTORY_LOOKUP_ERROR, _MD_GETHOST_ERRNO());
|
||||
@ -964,7 +964,7 @@ PR_IMPLEMENT(PRStatus) PR_GetIPNodeByName(
|
||||
#if defined(_PR_INET6) && defined(_PR_HAVE_GETIPNODEBYNAME)
|
||||
freehostent(h);
|
||||
#elif defined(_PR_INET6_PROBE) && defined(_PR_HAVE_GETIPNODEBYNAME)
|
||||
if (_pr_ipv6_is_present == PR_TRUE)
|
||||
if (_pr_ipv6_is_present())
|
||||
(*((_pr_freehostent_t)_pr_freehostent_fp))(h);
|
||||
#endif
|
||||
#if defined(_PR_INET6) && defined(_PR_HAVE_GETHOSTBYNAME2)
|
||||
@ -988,7 +988,7 @@ PR_IMPLEMENT(PRStatus) PR_GetIPNodeByName(
|
||||
#ifdef PR_GETIPNODE_NOT_THREADSAFE
|
||||
UNLOCK_DNS();
|
||||
#else
|
||||
if (_pr_ipv6_is_present == PR_FALSE)
|
||||
if (!_pr_ipv6_is_present())
|
||||
UNLOCK_DNS();
|
||||
#endif
|
||||
#else /* _PR_INET6 */
|
||||
@ -1027,10 +1027,7 @@ PR_IMPLEMENT(PRStatus) PR_GetHostByAddr(
|
||||
if (hostaddr->raw.family == PR_AF_INET6)
|
||||
{
|
||||
#if defined(_PR_INET6_PROBE)
|
||||
if (_pr_ipv6_is_present == PR_TRUE)
|
||||
af = AF_INET6;
|
||||
else
|
||||
af = AF_INET;
|
||||
af = _pr_ipv6_is_present() ? AF_INET6 : AF_INET;
|
||||
#elif defined(_PR_INET6)
|
||||
af = AF_INET6;
|
||||
#else
|
||||
@ -1089,7 +1086,7 @@ PR_IMPLEMENT(PRStatus) PR_GetHostByAddr(
|
||||
#if defined(_PR_HAVE_GETIPNODEBYADDR) && defined(_PR_INET6)
|
||||
h = getipnodebyaddr(addr, addrlen, af, &error_num);
|
||||
#elif defined(_PR_HAVE_GETIPNODEBYADDR) && defined(_PR_INET6_PROBE)
|
||||
if (_pr_ipv6_is_present == PR_TRUE)
|
||||
if (_pr_ipv6_is_present())
|
||||
{
|
||||
#ifdef PR_GETIPNODE_NOT_THREADSAFE
|
||||
LOCK_DNS();
|
||||
@ -1115,7 +1112,7 @@ PR_IMPLEMENT(PRStatus) PR_GetHostByAddr(
|
||||
#if defined(_PR_INET6) && defined(_PR_HAVE_GETIPNODEBYADDR)
|
||||
PR_SetError(PR_DIRECTORY_LOOKUP_ERROR, error_num);
|
||||
#elif defined(_PR_INET6_PROBE) && defined(_PR_HAVE_GETIPNODEBYADDR)
|
||||
if (_pr_ipv6_is_present == PR_TRUE)
|
||||
if (_pr_ipv6_is_present())
|
||||
PR_SetError(PR_DIRECTORY_LOOKUP_ERROR, error_num);
|
||||
else
|
||||
PR_SetError(PR_DIRECTORY_LOOKUP_ERROR, _MD_GETHOST_ERRNO());
|
||||
@ -1144,7 +1141,7 @@ PR_IMPLEMENT(PRStatus) PR_GetHostByAddr(
|
||||
#if defined(_PR_INET6) && defined(_PR_HAVE_GETIPNODEBYADDR)
|
||||
freehostent(h);
|
||||
#elif defined(_PR_INET6_PROBE) && defined(_PR_HAVE_GETIPNODEBYADDR)
|
||||
if (_pr_ipv6_is_present == PR_TRUE)
|
||||
if (_pr_ipv6_is_present())
|
||||
(*((_pr_freehostent_t)_pr_freehostent_fp))(h);
|
||||
#endif
|
||||
}
|
||||
@ -1155,7 +1152,7 @@ PR_IMPLEMENT(PRStatus) PR_GetHostByAddr(
|
||||
#ifdef PR_GETIPNODE_NOT_THREADSAFE
|
||||
UNLOCK_DNS();
|
||||
#else
|
||||
if (_pr_ipv6_is_present == PR_FALSE)
|
||||
if (!_pr_ipv6_is_present())
|
||||
UNLOCK_DNS();
|
||||
#endif
|
||||
#else /* _PR_HAVE_GETIPNODEBYADDR */
|
||||
@ -2015,7 +2012,7 @@ PR_IMPLEMENT(PRAddrInfo *) PR_GetAddrInfoByName(const char *hostname,
|
||||
return pr_GetAddrInfoByNameFB(hostname, af, flags);
|
||||
#else
|
||||
#if defined(_PR_INET6_PROBE)
|
||||
if (!_pr_ipv6_is_present) {
|
||||
if (!_pr_ipv6_is_present()) {
|
||||
return pr_GetAddrInfoByNameFB(hostname, af, flags);
|
||||
}
|
||||
#endif
|
||||
@ -2056,7 +2053,7 @@ PR_IMPLEMENT(void) PR_FreeAddrInfo(PRAddrInfo *ai)
|
||||
{
|
||||
#if defined(_PR_HAVE_GETADDRINFO)
|
||||
#if defined(_PR_INET6_PROBE)
|
||||
if (!_pr_ipv6_is_present)
|
||||
if (!_pr_ipv6_is_present())
|
||||
PR_Free((PRAddrInfoFB *) ai);
|
||||
else
|
||||
#endif
|
||||
@ -2074,7 +2071,7 @@ PR_IMPLEMENT(void *) PR_EnumerateAddrInfo(void *iterPtr,
|
||||
#if defined(_PR_HAVE_GETADDRINFO)
|
||||
PRADDRINFO *ai;
|
||||
#if defined(_PR_INET6_PROBE)
|
||||
if (!_pr_ipv6_is_present) {
|
||||
if (!_pr_ipv6_is_present()) {
|
||||
/* using PRAddrInfoFB */
|
||||
PRIntn iter = (PRIntn)(PRPtrdiff) iterPtr;
|
||||
iter = PR_EnumerateHostEnt(iter, &((PRAddrInfoFB *) base)->hostent, port, result);
|
||||
@ -2124,7 +2121,7 @@ PR_IMPLEMENT(const char *) PR_GetCanonNameFromAddrInfo(const PRAddrInfo *ai)
|
||||
{
|
||||
#if defined(_PR_HAVE_GETADDRINFO)
|
||||
#if defined(_PR_INET6_PROBE)
|
||||
if (!_pr_ipv6_is_present) {
|
||||
if (!_pr_ipv6_is_present()) {
|
||||
const PRAddrInfoFB *fb = (const PRAddrInfoFB *) ai;
|
||||
return fb->has_cname ? fb->hostent.h_name : NULL;
|
||||
}
|
||||
@ -2253,7 +2250,7 @@ PR_IMPLEMENT(PRStatus) PR_StringToNetAddr(const char *string, PRNetAddr *addr)
|
||||
return pr_StringToNetAddrFB(string, addr);
|
||||
#else
|
||||
#if defined(_PR_INET6_PROBE)
|
||||
if (!_pr_ipv6_is_present)
|
||||
if (!_pr_ipv6_is_present())
|
||||
return pr_StringToNetAddrFB(string, addr);
|
||||
#endif
|
||||
#if defined(DARWIN)
|
||||
@ -2359,7 +2356,7 @@ PR_IMPLEMENT(PRStatus) PR_NetAddrToString(
|
||||
return pr_NetAddrToStringFB(addr, string, size);
|
||||
#else
|
||||
#if defined(_PR_INET6_PROBE)
|
||||
if (!_pr_ipv6_is_present)
|
||||
if (!_pr_ipv6_is_present())
|
||||
return pr_NetAddrToStringFB(addr, string, size);
|
||||
#endif
|
||||
return pr_NetAddrToStringGNI(addr, string, size);
|
||||
|
||||
@ -3394,7 +3394,7 @@ failed:
|
||||
#if !defined(_PR_INET6) || defined(_PR_INET6_PROBE)
|
||||
PR_EXTERN(PRStatus) _pr_push_ipv6toipv4_layer(PRFileDesc *fd);
|
||||
#if defined(_PR_INET6_PROBE)
|
||||
PR_EXTERN(PRBool) _pr_ipv6_is_present;
|
||||
extern PRBool _pr_ipv6_is_present(void);
|
||||
PR_IMPLEMENT(PRBool) _pr_test_ipv6_socket()
|
||||
{
|
||||
PRInt32 osfd;
|
||||
@ -3453,12 +3453,8 @@ PR_IMPLEMENT(PRFileDesc*) PR_Socket(PRInt32 domain, PRInt32 type, PRInt32 proto)
|
||||
return fd;
|
||||
}
|
||||
#if defined(_PR_INET6_PROBE)
|
||||
if (PR_AF_INET6 == domain) {
|
||||
if (_pr_ipv6_is_present == PR_FALSE)
|
||||
domain = AF_INET;
|
||||
else
|
||||
domain = AF_INET6;
|
||||
}
|
||||
if (PR_AF_INET6 == domain)
|
||||
domain = _pr_ipv6_is_present() ? AF_INET6 : AF_INET;
|
||||
#elif defined(_PR_INET6)
|
||||
if (PR_AF_INET6 == domain)
|
||||
domain = AF_INET6;
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user