Fix for bug 121952 -- make PR_ConnectContinue work on Mac, re-enabling non-blocking connects. r=wtc. Also bring forward some code changes to build with CodeWarrior Pro 7 (UPP stuff).

This commit is contained in:
sfraser%netscape.com 2002-02-19 01:26:30 +00:00
parent d3ee9b756c
commit 855f941a23
5 changed files with 24 additions and 12 deletions

View File

@ -115,15 +115,18 @@ typedef struct _MDSocketCallerInfo {
struct _MDFileDesc {
PRInt32 osfd;
PRBool orderlyDisconnect;
PRBool readReady;
PRBool writeReady;
PRBool exceptReady;
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);
/*

View File

@ -347,7 +347,7 @@ static PRStatus PR_CALLBACK SocketConnectContinue(
#elif defined(XP_MAC)
err = _MD_mac_get_nonblocking_connect_error(osfd);
err = _MD_mac_get_nonblocking_connect_error(fd);
if (err == -1)
return PR_FAILURE;
else

View File

@ -267,7 +267,7 @@ PRInt32 ReadWriteProc(PRFileDesc *fd, void *buf, PRUint32 bytes, IOOperation op)
a 32 byte Ptr in the heap, so only do this once
*/
if (!sCompletionUPP)
sCompletionUPP = NewIOCompletionProc((IOCompletionProcPtr)&AsyncIOCompletion);
sCompletionUPP = NewIOCompletionUPP((IOCompletionProcPtr)&AsyncIOCompletion);
/* grab the thread so we know which one to post to at completion */
pbAsync.thread = me;

View File

@ -373,6 +373,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) {
@ -2197,25 +2199,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
}

View File

@ -199,7 +199,7 @@ void _MD_StartInterrupts(void)
gPrimaryThread = _PR_MD_CURRENT_THREAD();
if ( !gTimerCallbackUPP )
gTimerCallbackUPP = NewTimerProc(TimerCallback);
gTimerCallbackUPP = NewTimerUPP(TimerCallback);
// Fill in the Time Manager queue element