summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorsfraser%netscape.com <devnull@localhost>2002-02-19 01:09:46 +0000
committersfraser%netscape.com <devnull@localhost>2002-02-19 01:09:46 +0000
commit7f97092bda936b2433bf4c16b8b915383ce632c5 (patch)
tree2050965565f421bb94a5457e044b54b42b772db1
parent9f20ed505b4dff7f9b3d3456fa877ff9ef2a40d2 (diff)
downloadnspr-hg-7f97092bda936b2433bf4c16b8b915383ce632c5.tar.gz
Fix for bug 121952 -- make PR_ConnectContinue work on Mac, re-enabling non-blocking connects. r=wtc
-rw-r--r--pr/include/md/_macos.h31
-rw-r--r--pr/src/io/prsocket.c12
-rw-r--r--pr/src/md/mac/macsockotpt.c17
3 files changed, 31 insertions, 29 deletions
diff --git a/pr/include/md/_macos.h b/pr/include/md/_macos.h
index ccd54a83..7d9d0302 100644
--- a/pr/include/md/_macos.h
+++ b/pr/include/md/_macos.h
@@ -114,19 +114,22 @@ typedef struct _MDSocketCallerInfo {
} _MDSocketCallerInfo;
struct _MDFileDesc {
- PRInt32 osfd;
- PRBool orderlyDisconnect;
- PRBool readReady;
- PRBool writeReady;
- PRBool exceptReady;
- PRLock * miscLock;
-
- /* Server sockets: listen bit tells the notifier func what to do */
- PRBool doListen;
-
- _MDSocketCallerInfo misc;
- _MDSocketCallerInfo read;
- _MDSocketCallerInfo write;
+ PRInt32 osfd;
+ PRPackedBool orderlyDisconnect;
+ PRPackedBool readReady;
+ PRPackedBool writeReady;
+ PRPackedBool exceptReady;
+ PRLock * miscLock;
+
+ /* Server sockets: listen bit tells the notifier func what to do */
+ PRBool doListen;
+
+ /* stored error for non-blocking connects, as a Unix-style error code */
+ OTReason disconnectError;
+
+ _MDSocketCallerInfo misc;
+ _MDSocketCallerInfo read;
+ _MDSocketCallerInfo write;
};
/*
@@ -647,7 +650,7 @@ extern PRStatus _MD_CloseFileMap(struct PRFileMap *fmap);
#define _MD_CLOSE_FILE_MAP _MD_CloseFileMap
extern void SetLogFileTypeCreator(const char *logFile);
-extern int _MD_mac_get_nonblocking_connect_error(PRInt32 osfd);
+extern int _MD_mac_get_nonblocking_connect_error(PRFileDesc* fd);
/*
diff --git a/pr/src/io/prsocket.c b/pr/src/io/prsocket.c
index 24b80227..d8968636 100644
--- a/pr/src/io/prsocket.c
+++ b/pr/src/io/prsocket.c
@@ -347,21 +347,11 @@ static PRStatus PR_CALLBACK SocketConnectContinue(
#elif defined(XP_MAC)
-#if 0
- err = _MD_mac_get_nonblocking_connect_error(osfd);
+ err = _MD_mac_get_nonblocking_connect_error(fd);
if (err == -1)
return PR_FAILURE;
else
return PR_SUCCESS;
-#else
- if (out_flags & PR_POLL_EXCEPT) {
- PR_SetError(PR_CONNECT_REFUSED_ERROR, 0);
- return PR_FAILURE;
- }
-
- PR_ASSERT(out_flags & PR_POLL_WRITE);
- return PR_SUCCESS;
-#endif
#elif defined(XP_BEOS)
diff --git a/pr/src/md/mac/macsockotpt.c b/pr/src/md/mac/macsockotpt.c
index f675b61c..2f52c9f6 100644
--- a/pr/src/md/mac/macsockotpt.c
+++ b/pr/src/md/mac/macsockotpt.c
@@ -375,6 +375,8 @@ static pascal void NotifierRoutine(void * contextPtr, OTEventCode code, OTResul
PR_ASSERT(err == kOTNoError);
secret->md.exceptReady = PR_TRUE; // XXX Check this
+ md->disconnectError = discon.reason; // save for _MD_mac_get_nonblocking_connect_error
+
// wake up waiting threads, if any
result = -3199 - discon.reason; // obtain the negative error code
if ((readThread = secret->md.read.thread) != NULL) {
@@ -2200,25 +2202,32 @@ ErrorExit:
}
-int _MD_mac_get_nonblocking_connect_error(PRInt32 osfd)
+int _MD_mac_get_nonblocking_connect_error(PRFileDesc* fd)
{
- OTResult resultOT;
- EndpointRef endpoint = (EndpointRef) osfd;
+ EndpointRef endpoint = (EndpointRef)fd->secret->md.osfd;
+ OTResult resultOT = OTGetEndpointState(endpoint);
- resultOT = OTGetEndpointState(endpoint);
switch (resultOT) {
case T_OUTCON:
macsock_map_error(EINPROGRESS);
return -1;
+
case T_DATAXFER:
return 0;
+
case T_IDLE:
+ macsock_map_error(fd->secret->md.disconnectError);
+ fd->secret->md.disconnectError = 0;
return -1;
+
case T_INREL:
macsock_map_error(ENOTCONN);
return -1;
+
default:
PR_ASSERT(0);
return -1;
}
+
+ return -1; // not reached
}