summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorcls%seawood.org <devnull@localhost>1999-09-12 01:09:35 +0000
committercls%seawood.org <devnull@localhost>1999-09-12 01:09:35 +0000
commit6fcde6a0759313b21f3e05dec3a956335eae6f90 (patch)
tree46df5ad69adf58ae05e061d33874ea10e5f0faf4
parent4bc231f1759665e3d5bcbdedf1d01c4e351767e5 (diff)
downloadnspr-hg-unlabeled-3.9.20.tar.gz
Merged changes made to HEAD branch.unlabeled-3.9.20
-rw-r--r--pr/src/md/mac/macsockotpt.c32
1 files changed, 30 insertions, 2 deletions
diff --git a/pr/src/md/mac/macsockotpt.c b/pr/src/md/mac/macsockotpt.c
index 205c58f7..dd9f5ad7 100644
--- a/pr/src/md/mac/macsockotpt.c
+++ b/pr/src/md/mac/macsockotpt.c
@@ -42,6 +42,7 @@ static struct {
void * cookie;
} dnsContext;
+static PRBool gOTInitialized;
static pascal void DNSNotifierRoutine(void * contextPtr, OTEventCode code, OTResult result, void * cookie);
static pascal void NotifierRoutine(void * contextPtr, OTEventCode code,
@@ -111,6 +112,15 @@ void _MD_InitNetAccess()
dnsContext.thread = _PR_MD_CURRENT_THREAD();
dnsContext.cookie = NULL;
+ gOTInitialized = PR_FALSE;
+
+/* XXX Does not handle absence of open tpt and tcp yet! */
+}
+
+static void _MD_FinishInitNetAccess()
+{
+ OSStatus errOT;
+
dnsContext.serviceRef = OT_OPEN_INTERNET_SERVICES(kDefaultInternetServicesPath, NULL, &errOT);
if (errOT != kOTNoError) return; /* no network -- oh well */
PR_ASSERT((dnsContext.serviceRef != NULL) && (errOT == kOTNoError));
@@ -122,8 +132,8 @@ void _MD_InitNetAccess()
/* Put us into async mode */
errOT = OTSetAsynchronous(dnsContext.serviceRef);
PR_ASSERT(errOT == kOTNoError);
-
-/* XXX Does not handle absence of open tpt and tcp yet! */
+
+ gOTInitialized = PR_TRUE;
}
@@ -416,6 +426,9 @@ PRInt32 _MD_socket(int domain, int type, int protocol)
{
OSStatus err;
EndpointRef endpoint;
+
+ if (!gOTInitialized)
+ _MD_FinishInitNetAccess();
// We only deal with internet domain
if (domain != AF_INET) {
@@ -1586,6 +1599,9 @@ PR_IMPLEMENT(unsigned long) inet_addr(const char *cp)
OSStatus err;
InetHost host;
+ if (!gOTInitialized)
+ _MD_FinishInitNetAccess();
+
err = OTInetStringToHost((char*) cp, &host);
PR_ASSERT(err == kOTNoError);
@@ -1605,6 +1621,9 @@ PR_IMPLEMENT(struct hostent *) gethostbyname(const char * name)
PRUint32 index;
PRThread *me = _PR_MD_CURRENT_THREAD();
+ if (!gOTInitialized)
+ _MD_FinishInitNetAccess();
+
me->io_pending = PR_TRUE;
me->io_fd = NULL;
me->md.osErrCode = noErr;
@@ -1643,6 +1662,9 @@ PR_IMPLEMENT(struct hostent *) gethostbyaddr(const void *addr, int addrlen, int
PR_ASSERT(type == AF_INET);
PR_ASSERT(addrlen == sizeof(struct in_addr));
+ if (!gOTInitialized)
+ _MD_FinishInitNetAccess();
+
OTInetHostToString((InetHost)addr, sHostInfo.name);
return (gethostbyname(sHostInfo.name));
@@ -1651,6 +1673,9 @@ PR_IMPLEMENT(struct hostent *) gethostbyaddr(const void *addr, int addrlen, int
PR_IMPLEMENT(char *) inet_ntoa(struct in_addr addr)
{
+ if (!gOTInitialized)
+ _MD_FinishInitNetAccess();
+
OTInetHostToString((InetHost)addr.s_addr, sHostInfo.name);
return sHostInfo.name;
@@ -1662,6 +1687,9 @@ PRStatus _MD_gethostname(char *name, int namelen)
OSStatus err;
InetInterfaceInfo info;
+ if (!gOTInitialized)
+ _MD_FinishInitNetAccess();
+
/*
* On a Macintosh, we don't have the concept of a local host name.
* We do though have an IP address & everyone should be happy with