summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorwtc%netscape.com <devnull@localhost>2003-02-27 22:23:19 +0000
committerwtc%netscape.com <devnull@localhost>2003-02-27 22:23:19 +0000
commit3b227b34121d43ce5d989100ecaa92277aeb08b1 (patch)
treedd4c1880d7fa8a0d944594a06815bcb955046dce
parent33e920a330cb54239a73a66ef365e0a559c660b0 (diff)
downloadnspr-hg-MOZILLA_1_3_BRANCH.tar.gz
Bug 192589: keep querying the presence of IPv4 and IPv6 interfaces until atMOZILLA_1_3_BRANCH
least one is up. This allows us to detect the local machine going from offline to online. Tag: MOZILLA_1_3_BRANCH
-rw-r--r--pr/src/misc/prnetdb.c34
1 files changed, 27 insertions, 7 deletions
diff --git a/pr/src/misc/prnetdb.c b/pr/src/misc/prnetdb.c
index f6699422..50b98c61 100644
--- a/pr/src/misc/prnetdb.c
+++ b/pr/src/misc/prnetdb.c
@@ -177,6 +177,7 @@ const PRIPv6Addr _pr_in6addr_loopback = {{{ 0, 0, 0, 0,
* W. Richard Stevens' Unix Network Programming, Vol. 1, 2nd. Ed.)
*/
+static PRLock *_pr_query_ifs_lock = NULL;
static PRBool _pr_have_inet_if = PR_FALSE;
static PRBool _pr_have_inet6_if = PR_FALSE;
@@ -423,13 +424,7 @@ void _PR_InitNet(void)
_getproto_lock = PR_NewLock();
#endif
#if defined(_PR_INET6) && defined(_PR_HAVE_GETHOSTBYNAME2)
- _pr_QueryNetIfs();
-#ifdef DEBUG_QUERY_IFS
- if (_pr_have_inet_if)
- printf("Have IPv4 source address\n");
- if (_pr_have_inet6_if)
- printf("Have IPv6 source address\n");
-#endif
+ _pr_query_ifs_lock = PR_NewLock();
#endif
}
@@ -447,6 +442,12 @@ void _PR_CleanupNet(void)
_getproto_lock = NULL;
}
#endif
+#if defined(_PR_INET6) && defined(_PR_HAVE_GETHOSTBYNAME2)
+ if (_pr_query_ifs_lock) {
+ PR_DestroyLock(_pr_query_ifs_lock);
+ _pr_query_ifs_lock = NULL;
+ }
+#endif
}
/*
@@ -792,6 +793,25 @@ PR_IMPLEMENT(PRStatus) PR_GetIPNodeByName(
return PR_FAILURE;
}
+#if defined(_PR_INET6) && defined(_PR_HAVE_GETHOSTBYNAME2)
+ PR_Lock(_pr_query_ifs_lock);
+ /*
+ * Keep querying the presence of IPv4 and IPv6 interfaces until
+ * at least one is up. This allows us to detect the local
+ * machine going from offline to online.
+ */
+ if (!_pr_have_inet_if && !_pr_have_inet6_if) {
+ _pr_QueryNetIfs();
+#ifdef DEBUG_QUERY_IFS
+ if (_pr_have_inet_if)
+ printf("Have IPv4 source address\n");
+ if (_pr_have_inet6_if)
+ printf("Have IPv6 source address\n");
+#endif
+ }
+ PR_Unlock(_pr_query_ifs_lock);
+#endif
+
#if defined(_PR_HAVE_GETIPNODEBYNAME)
if (flags & PR_AI_V4MAPPED)
tmp_flags |= AI_V4MAPPED;