diff options
author | wtc <devnull@localhost> | 1998-06-26 20:24:25 +0000 |
---|---|---|
committer | wtc <devnull@localhost> | 1998-06-26 20:24:25 +0000 |
commit | 63ffdf90e758a5456255ad2b72b028ad2f4c28d3 (patch) | |
tree | 0eb82a19979ec64c405915b7b563b9c94c68c578 | |
parent | 9b236265d78a78bd490534d4bfbf900c23f11934 (diff) | |
download | nspr-hg-63ffdf90e758a5456255ad2b72b028ad2f4c28d3.tar.gz |
Bug #180965: Mac gets PR_IO_PENDING_ERROR. In
SendReceiveStream and SendReceiveDgram, make
sure that we set the io_pending flag of the current
thread to PR_FALSE before we return.
In gethostbyname(), just store the OS error code in
me->md.osErrCode. Do not call macsock_map_error()
to map to NSPR error code.
-rw-r--r-- | pr/src/md/mac/macsockotpt.c | 38 |
1 files changed, 24 insertions, 14 deletions
diff --git a/pr/src/md/mac/macsockotpt.c b/pr/src/md/mac/macsockotpt.c index a227c063..04217a74 100644 --- a/pr/src/md/mac/macsockotpt.c +++ b/pr/src/md/mac/macsockotpt.c @@ -242,8 +242,11 @@ pascal void NotifierRoutine(void * contextPtr, OTEventCode code, OTResult resul // UDP Send error; clear the error case T_UDERR: (void) OTRcvUDErr((EndpointRef) cookie, NULL); + break; + default: PR_ASSERT(0); + break; } } @@ -1023,6 +1026,11 @@ static PRInt32 SendReceiveStream(PRFileDesc *fd, void *buf, PRInt32 amount, err = kEFAULTErr; goto ErrorExit; } + + if (opCode != kSTREAM_SEND && opCode != kSTREAM_RECEIVE) { + err = kEINVALErr; + goto ErrorExit; + } while (bytesLeft > 0) { @@ -1030,12 +1038,8 @@ static PRInt32 SendReceiveStream(PRFileDesc *fd, void *buf, PRInt32 amount, if (opCode == kSTREAM_SEND) result = OTSnd(endpoint, buf, bytesLeft, NULL); - else if (opCode == kSTREAM_RECEIVE) + else result = OTRcv(endpoint, buf, bytesLeft, NULL); - else { - err = kEINVALErr; - goto ErrorExit; - } if (result > 0) { buf = (void *) ( (UInt32) buf + (UInt32)result ); @@ -1045,6 +1049,7 @@ static PRInt32 SendReceiveStream(PRFileDesc *fd, void *buf, PRInt32 amount, return result; } else { if (result == kOTOutStateErr) { /* it has been closed */ + me->io_pending = PR_FALSE; return 0; } if (result == kOTLookErr) { @@ -1055,6 +1060,7 @@ static PRInt32 SendReceiveStream(PRFileDesc *fd, void *buf, PRInt32 amount, } if (result != kOTNoDataErr && result != kOTFlowErr && result != kEAGAINErr && result != kEWOULDBLOCKErr) { + me->io_pending = PR_FALSE; err = result; goto ErrorExit; } else if (fd->secret->nonblocking) { @@ -1063,6 +1069,7 @@ static PRInt32 SendReceiveStream(PRFileDesc *fd, void *buf, PRInt32 amount, goto ErrorExit; } WaitOnThisThread(me, timeout); + me->io_pending = PR_FALSE; err = me->md.osErrCode; if (err != kOTNoError) goto ErrorExit; @@ -1116,6 +1123,11 @@ static PRInt32 SendReceiveDgram(PRFileDesc *fd, void *buf, PRInt32 amount, err = kEFAULTErr; goto ErrorExit; } + + if (opCode != kDGRAM_SEND && opCode != kDGRAM_RECEIVE) { + err = kEINVALErr; + goto ErrorExit; + } memset(&dgram, 0 , sizeof(dgram)); dgram.addr.maxlen = *addrlen; @@ -1131,12 +1143,8 @@ static PRInt32 SendReceiveDgram(PRFileDesc *fd, void *buf, PRInt32 amount, if (opCode == kDGRAM_SEND) err = OTSndUData(endpoint, &dgram); - else if (opCode == kDGRAM_RECEIVE) + else err = OTRcvUData(endpoint, &dgram, NULL); - else { - err = kEINVALErr; - goto ErrorExit; - } if (err == kOTNoError) { buf = (void *) ( (UInt32) buf + (UInt32)dgram.udata.len ); @@ -1147,6 +1155,7 @@ static PRInt32 SendReceiveDgram(PRFileDesc *fd, void *buf, PRInt32 amount, else { PR_ASSERT(err == kOTNoDataErr || err == kOTOutStateErr); WaitOnThisThread(me, timeout); + me->io_pending = PR_FALSE; err = me->md.osErrCode; if (err != kOTNoError) goto ErrorExit; @@ -1407,13 +1416,15 @@ PR_IMPLEMENT(struct hostent *) gethostbyname(const char * name) PrepareThreadForAsyncIO(me, sSvcRef, NULL); err = OTInetStringToAddress(sSvcRef, (char *)name, &sHostInfo); - if (err != kOTNoError) + if (err != kOTNoError) { + me->io_pending = PR_FALSE; + me->md.osErrCode = err; goto ErrorExit; + } WaitOnThisThread(me, PR_INTERVAL_NO_TIMEOUT); - err = me->md.osErrCode; - if (err != kOTNoError) + if (me->md.osErrCode != kOTNoError) goto ErrorExit; sHostEnt.h_name = sHostInfo.name; @@ -1425,7 +1436,6 @@ PR_IMPLEMENT(struct hostent *) gethostbyname(const char * name) return (&sHostEnt); ErrorExit: - macsock_map_error(err); return NULL; } |