From f17c1141674eda392cf72b214899ceb336d2c2fc Mon Sep 17 00:00:00 2001 From: "wtc%netscape.com" Date: Fri, 2 Mar 2001 02:40:52 +0000 Subject: [PATCH] Bugzilla bug #62877: checked in patches contributed by Javier Pedemonte and Dmitry Kubov . Modified files: prinet.h, _os2.h, os2poll.c, and os2sock.c. --- nsprpub/pr/include/md/_os2.h | 12 ++ nsprpub/pr/include/prinet.h | 2 +- nsprpub/pr/src/md/os2/os2poll.c | 154 +++++++++++++++++- nsprpub/pr/src/md/os2/os2sock.c | 268 +++++++++++++++++++------------- 4 files changed, 321 insertions(+), 115 deletions(-) diff --git a/nsprpub/pr/include/md/_os2.h b/nsprpub/pr/include/md/_os2.h index 417f721c875d..70cf9450910a 100644 --- a/nsprpub/pr/include/md/_os2.h +++ b/nsprpub/pr/include/md/_os2.h @@ -59,6 +59,11 @@ #define sock_errno() errno #define soclose close #define sock_init() + +#include +#include +static _smutex _md_shm_lock = 0; + #endif /* @@ -269,7 +274,14 @@ extern PRInt32 _MD_CloseSocket(PRInt32 osfd); #define _MD_GETPEERNAME (_PR_MD_GETPEERNAME) #define _MD_GETSOCKOPT (_PR_MD_GETSOCKOPT) #define _MD_SETSOCKOPT (_PR_MD_SETSOCKOPT) + +#ifdef XP_OS2_EMX +extern PRInt32 _MD_SELECT(int nfds, fd_set *readfds, fd_set *writefds, + fd_set *exceptfds, struct timeval *timeout); +#else #define _MD_SELECT select +#endif + #define _MD_FSYNC _PR_MD_FSYNC #define _MD_SET_FD_INHERITABLE (_PR_MD_SET_FD_INHERITABLE) diff --git a/nsprpub/pr/include/prinet.h b/nsprpub/pr/include/prinet.h index 842650a9cddb..f5aea7eb54c1 100644 --- a/nsprpub/pr/include/prinet.h +++ b/nsprpub/pr/include/prinet.h @@ -91,7 +91,7 @@ struct sockaddr_dl; * socket headers. */ #if defined(OS2) && !defined(INADDR_LOOPBACK) -#define INADDR_LOOPBACK gethostid() +#define INADDR_LOOPBACK 0x7f000001 #endif /* diff --git a/nsprpub/pr/src/md/os2/os2poll.c b/nsprpub/pr/src/md/os2/os2poll.c index c7c1e440053b..12f199f65364 100644 --- a/nsprpub/pr/src/md/os2/os2poll.c +++ b/nsprpub/pr/src/md/os2/os2poll.c @@ -77,6 +77,9 @@ PRInt32 _PR_MD_PR_POLL( return 0; } + remaining = timeout; + start = PR_IntervalNow(); + FD_ZERO(&rd); FD_ZERO(&wt); FD_ZERO(&ex); @@ -177,9 +180,6 @@ PRInt32 _PR_MD_PR_POLL( if (0 != ready) return ready; /* no need to block */ - remaining = timeout; - start = PR_IntervalNow(); - retry: if (timeout != PR_INTERVAL_NO_TIMEOUT) { @@ -276,3 +276,151 @@ retry: return ready; } +#ifdef XP_OS2_EMX +HMTX thread_select_mutex = 0; /* because EMX's select is not thread safe - duh! */ + +typedef struct _thread_select_st { + int nfds; + int isrdfds; + struct _fd_set *readfds; + int iswrfds; + struct _fd_set *writefds; + int isexfds; + struct _fd_set *exceptfds; + int istimeout; + struct timeval timeout; + volatile HEV event; + int result; + int select_errno; + volatile int done; +} *pthread_select_t; + +void _thread_select(void * arg) +{ + pthread_select_t self = arg; + int result, chkstdin; + struct _fd_set readfds; + struct _fd_set writefds; + struct _fd_set exceptfds; + HEV event = self->event; + + chkstdin = (self->isrdfds && FD_ISSET(0,self->readfds))?1:0; + + do { + struct timeval timeout = {0L,0L}; + + + if (self->isrdfds) readfds = *self->readfds; + if (self->iswrfds) writefds = *self->writefds; + if (self->isexfds) exceptfds = *self->exceptfds; + + if (chkstdin) FD_CLR(0,&readfds); + + if (!thread_select_mutex) + DosCreateMutexSem(NULL,&thread_select_mutex,0,1); + else + DosRequestMutexSem(thread_select_mutex,SEM_INDEFINITE_WAIT); + result = select( + self->nfds, + self->isrdfds?&readfds:NULL, + self->iswrfds?&writefds:NULL, + self->isexfds?&exceptfds:NULL, + &timeout); + DosReleaseMutexSem(thread_select_mutex); + + if (chkstdin) { + int charcount = 0, res; + res = ioctl(0,FIONREAD,&charcount); + if (res==0 && charcount>0) FD_SET(0,&readfds); + } + + if (result>0) { + self->done++; + if (self->isrdfds) *self->readfds = readfds; + if (self->iswrfds) *self->writefds = writefds; + if (self->isexfds) *self->exceptfds = exceptfds; + } else + if (result) self->done++; + else DosSleep(1); + + } while (self->event!=0 && self->done==0); + + if (self->event) { + self->select_errno = (result < 0)?errno:0; + self->result = result; + self->done = 3; + DosPostEventSem(event); + } else { + self->done = 3; + free(self); + } + +} + +PRInt32 +_MD_SELECT(int nfds, fd_set *readfds, fd_set *writefds, + fd_set *exceptfds, struct timeval *timeout) +{ + pthread_select_t sel; + HEV ev = 0; + HTIMER timer = 0; + int result = 0; + APIRET rc; + unsigned long msecs = SEM_INDEFINITE_WAIT; + + if (timeout) { + if (timeout->tv_sec != 0 || timeout->tv_usec != 0) + msecs = (timeout->tv_sec * 1000L) + (timeout->tv_usec / 1000L); + else + msecs = SEM_IMMEDIATE_RETURN; + }; + + if (!(sel = (pthread_select_t) malloc(sizeof(struct _thread_select_st)))) { + result = -1; + errno = ENOMEM; + } else { + sel->nfds = nfds; + sel->isrdfds = readfds?1:0; + if (sel->isrdfds) sel->readfds = readfds; + sel->iswrfds = writefds?1:0; + if (sel->iswrfds) sel->writefds = writefds; + sel->isexfds = exceptfds?1:0; + if (sel->isexfds) sel->exceptfds = exceptfds; + sel->istimeout = timeout?1:0; + if (sel->istimeout) sel->timeout = *timeout; + + rc = DosCreateEventSem(NULL,&ev,0,FALSE); + + sel->event = ev; + if (msecs == SEM_IMMEDIATE_RETURN) + sel->done = 1; + else + sel->done = 0; + + if (_beginthread(_thread_select,NULL,65536,(void *)sel) == -1) { + result = -1; sel->event = 0; + DosCloseEventSem(ev); + } else { + rc = DosWaitEventSem(ev,msecs); + if ((!sel->done) && (msecs != SEM_IMMEDIATE_RETURN)) { /* Interrupted by other thread or timeout */ + sel->event = 0; + result = 0; + errno = ETIMEDOUT; + + } else { + while (sel->done && sel->done != 3) { + DosSleep(1); + } + sel->event = 0; + result = sel->result; + if (sel->select_errno) errno = sel->select_errno; + free(sel); + } + rc = DosCloseEventSem(ev); + } + } + + return (result); +} + +#endif diff --git a/nsprpub/pr/src/md/os2/os2sock.c b/nsprpub/pr/src/md/os2/os2sock.c index 03339e420b0d..529e0e5a4863 100644 --- a/nsprpub/pr/src/md/os2/os2sock.c +++ b/nsprpub/pr/src/md/os2/os2sock.c @@ -72,7 +72,7 @@ _PR_MD_SOCKET(int af, int type, int flags) { int rv = sock_errno(); soclose(sock); - _PR_MD_MAP_SOCKET_ERROR(rv); + _PR_MD_MAP_SOCKET_ERROR(rv); return (PRInt32) -1; } @@ -99,8 +99,8 @@ _MD_CloseSocket(PRInt32 osfd) PRInt32 rv = -1; rv = soclose((int) osfd ); - if (rv < 0) - _PR_MD_MAP_SOCKET_ERROR(sock_errno()); + if (rv < 0) + _PR_MD_MAP_SOCKET_ERROR(sock_errno()); return rv; } @@ -111,7 +111,7 @@ _MD_SocketAvailable(PRFileDesc *fd) PRInt32 result; if (ioctl(fd->secret->md.osfd, FIONREAD, (char *) &result, sizeof(result)) < 0) { - PR_SetError(PR_BAD_DESCRIPTOR_ERROR, sock_errno()); + PR_SetError(PR_BAD_DESCRIPTOR_ERROR, sock_errno()); return -1; } return result; @@ -141,18 +141,18 @@ _MD_Accept(PRFileDesc *fd, PRNetAddr *raddr, PRUint32 *rlen, && (!fd->secret->nonblocking)) { #ifdef BSD_SELECT - if ((rv = select(osfd + 1, &rd, NULL, NULL,NULL)) == -1) { + if ((rv = _MD_SELECT(osfd + 1, &rd, NULL, NULL,NULL)) == -1) { #else - if ((rv = select(socks, 1, 0, 0, -1)) == -1) { + if ((rv = _MD_SELECT(socks, 1, 0, 0, -1)) == -1) { #endif - _PR_MD_MAP_SELECT_ERROR(sock_errno()); + _PR_MD_MAP_SELECT_ERROR(sock_errno()); break; - } + } } else { - _PR_MD_MAP_ACCEPT_ERROR(err); + _PR_MD_MAP_ACCEPT_ERROR(err); break; - } + } } return(rv); } @@ -163,14 +163,14 @@ _MD_Accept(PRFileDesc *fd, PRNetAddr *raddr, PRUint32 *rlen, if (((err = sock_errno()) == EWOULDBLOCK) && (!fd->secret->nonblocking)) { - PR_SetError(PR_IO_TIMEOUT_ERROR, 0); + PR_SetError(PR_IO_TIMEOUT_ERROR, 0); } else { _PR_MD_MAP_ACCEPT_ERROR(err); } } - return(rv); + return(rv); } else { @@ -182,26 +182,25 @@ retry: { #ifdef BSD_SELECT tv.tv_sec = PR_IntervalToSeconds(timeout); - tv.tv_usec = PR_IntervalToMicroseconds( - timeout - PR_SecondsToInterval(tv.tv_sec)); + tv.tv_usec = PR_IntervalToMicroseconds(timeout - PR_SecondsToInterval(tv.tv_sec)); tvp = &tv; - rv = select(osfd + 1, &rd, NULL, NULL, tvp); + rv = _MD_SELECT(osfd + 1, &rd, NULL, NULL, tvp); #else long lTimeout = PR_IntervalToMilliseconds(timeout); - rv = select(socks, 1, 0, 0, lTimeout); + rv = _MD_SELECT(socks, 1, 0, 0, lTimeout); #endif if (rv > 0) { goto retry; } else if (rv == 0) { - PR_SetError(PR_IO_TIMEOUT_ERROR, 0); + PR_SetError(PR_IO_TIMEOUT_ERROR, 0); rv = -1; } else { - _PR_MD_MAP_SELECT_ERROR(sock_errno()); + _PR_MD_MAP_SELECT_ERROR(sock_errno()); } } else { - _PR_MD_MAP_ACCEPT_ERROR(err); + _PR_MD_MAP_ACCEPT_ERROR(err); } } } @@ -218,7 +217,11 @@ _PR_MD_CONNECT(PRFileDesc *fd, const PRNetAddr *addr, PRUint32 addrlen, PRInt32 rv; int err, len; #ifdef BSD_SELECT +#ifdef XP_OS2//_VACPP + fd_set wd; +#else fd_set wd, ex; +#endif #vacpp struct timeval tv, *tvp; #else int socks[1]; @@ -236,17 +239,20 @@ _PR_MD_CONNECT(PRFileDesc *fd, const PRNetAddr *addr, PRUint32 addrlen, else { tv.tv_sec = PR_IntervalToSeconds(timeout); - tv.tv_usec = PR_IntervalToMicroseconds( - timeout - PR_SecondsToInterval(tv.tv_sec)); + tv.tv_usec = PR_IntervalToMicroseconds(timeout - PR_SecondsToInterval(tv.tv_sec)); tvp = &tv; } FD_ZERO(&wd); FD_SET(osfd, &wd); +#ifdef XP_OS2//_VACPP + rv = _MD_SELECT(osfd + 1, NULL, &wd, NULL, tvp); +#else FD_ZERO(&ex); FD_SET(osfd, &ex); - rv = select(osfd + 1, NULL, &wd, &ex, tvp); -#else + rv = _MD_SELECT(osfd + 1, NULL, &wd, &ex, tvp); +#endif #vacpp +#else #!bsd_select if (timeout == PR_INTERVAL_NO_TIMEOUT) lTimeout = -1; else @@ -255,11 +261,38 @@ _PR_MD_CONNECT(PRFileDesc *fd, const PRNetAddr *addr, PRUint32 addrlen, } socks[0] = osfd; - rv = select(socks, 0, 1, 1, lTimeout); +#ifdef XP_OS2//_VACPP + rv = _MD_SELECT(socks, 0, 1, 0, lTimeout); +#else + rv = _MD_SELECT(socks, 0, 1, 1, lTimeout); +#endif #vacpp #endif if (rv > 0) { #ifdef BSD_SELECT +#ifdef XP_OS2//_VACPP + if (FD_ISSET(osfd, &wd)) + { + //DosSleep(0); + len = sizeof(err); + if (getsockopt(osfd, SOL_SOCKET, SO_ERROR, + (char *) &err, &len) < 0) + { + _PR_MD_MAP_GETSOCKOPT_ERROR(sock_errno()); + return -1; + } + + if (err != 0) + { + _PR_MD_MAP_CONNECT_ERROR(err); + return -1; + } + else + return 0; /* it's connected */ + } + else + return -1; +#else if (FD_ISSET(osfd, &ex)) { DosSleep(0); @@ -281,24 +314,37 @@ _PR_MD_CONNECT(PRFileDesc *fd, const PRNetAddr *addr, PRUint32 addrlen, /* it's connected */ return 0; } -#else - if (getsockopt(osfd, SOL_SOCKET, SO_ERROR, - (char *) &err, &len) < 0) - { - _PR_MD_MAP_GETSOCKOPT_ERROR(sock_errno()); - return -1; - } - else - return 0; /* It's connected ! */ +#endif #vacpp +#else #!bsd_select + if (socks[0] == osfd) + { + len = sizeof(err); + if (getsockopt(osfd, SOL_SOCKET, SO_ERROR, + (char *) &err, &len) < 0) + { + _PR_MD_MAP_GETSOCKOPT_ERROR(sock_errno()); + return -1; + } + + if (err != 0) + { + _PR_MD_MAP_CONNECT_ERROR(err); + return -1; + } + else + return 0; /* it's connected */ + } + else + return -1; #endif - } + } else if (rv == 0) { - PR_SetError(PR_IO_TIMEOUT_ERROR, 0); + PR_SetError(PR_IO_TIMEOUT_ERROR, 0); return(-1); } else if (rv < 0) { - _PR_MD_MAP_SELECT_ERROR(sock_errno()); + _PR_MD_MAP_SELECT_ERROR(sock_errno()); return(-1); } } @@ -364,7 +410,7 @@ _PR_MD_RECV(PRFileDesc *fd, void *buf, PRInt32 amount, PRIntn flags, timeout - PR_SecondsToInterval(tv.tv_sec)); tvp = &tv; } - if ((rv = select(osfd + 1, &rd, NULL, NULL, tvp)) == -1) + if ((rv = _MD_SELECT(osfd + 1, &rd, NULL, NULL, tvp)) == -1) #else socks[0] = osfd; if (timeout == PR_INTERVAL_NO_TIMEOUT) @@ -375,22 +421,22 @@ _PR_MD_RECV(PRFileDesc *fd, void *buf, PRInt32 amount, PRIntn flags, { lTimeout = PR_IntervalToMilliseconds(timeout); } - if ((rv = select(socks, 1, 0, 0, lTimeout)) == -1) + if ((rv = _MD_SELECT(socks, 1, 0, 0, lTimeout)) == -1) #endif { - _PR_MD_MAP_SELECT_ERROR(sock_errno()); + _PR_MD_MAP_SELECT_ERROR(sock_errno()); return -1; } else if (rv == 0) { - PR_SetError(PR_IO_TIMEOUT_ERROR, 0); + PR_SetError(PR_IO_TIMEOUT_ERROR, 0); rv = -1; break; } } else { - _PR_MD_MAP_RECV_ERROR(err); + _PR_MD_MAP_RECV_ERROR(err); break; } } /* end while() */ @@ -433,7 +479,7 @@ _PR_MD_SEND(PRFileDesc *fd, const void *buf, PRInt32 amount, PRIntn flags, } FD_ZERO(&wd); FD_SET(osfd, &wd); - if ((rv = select( osfd + 1, NULL, &wd, NULL,tvp)) == -1) { + if ((rv = _MD_SELECT( osfd + 1, NULL, &wd, NULL,tvp)) == -1) { #else if ( timeout == PR_INTERVAL_NO_TIMEOUT ) { @@ -444,21 +490,21 @@ _PR_MD_SEND(PRFileDesc *fd, const void *buf, PRInt32 amount, PRIntn flags, lTimeout = PR_IntervalToMilliseconds(timeout); } socks[0] = osfd; - if ((rv = select( socks, 0, 1, 0, lTimeout)) == -1) { + if ((rv = _MD_SELECT( socks, 0, 1, 0, lTimeout)) == -1) { #endif - _PR_MD_MAP_SELECT_ERROR(sock_errno()); + _PR_MD_MAP_SELECT_ERROR(sock_errno()); break; - } + } if (rv == 0) { - PR_SetError(PR_IO_TIMEOUT_ERROR, 0); - return -1; + PR_SetError(PR_IO_TIMEOUT_ERROR, 0); + return -1; } } else { - _PR_MD_MAP_SEND_ERROR(err); + _PR_MD_MAP_SEND_ERROR(err); return -1; - } + } } bytesSent += rv; if (fd->secret->nonblocking) @@ -481,7 +527,7 @@ _PR_MD_SEND(PRFileDesc *fd, const void *buf, PRInt32 amount, PRIntn flags, } FD_ZERO(&wd); FD_SET(osfd, &wd); - if ((rv = select(osfd + 1, NULL, &wd, NULL,tvp)) == -1) { + if ((rv = _MD_SELECT(osfd + 1, NULL, &wd, NULL,tvp)) == -1) { #else if ( timeout == PR_INTERVAL_NO_TIMEOUT ) { @@ -492,15 +538,15 @@ _PR_MD_SEND(PRFileDesc *fd, const void *buf, PRInt32 amount, PRIntn flags, lTimeout = PR_IntervalToMilliseconds(timeout); } socks[0] = osfd; - if ((rv = select(socks, 0, 1, 0,lTimeout)) == -1) { + if ((rv = _MD_SELECT(socks, 0, 1, 0,lTimeout)) == -1) { #endif - _PR_MD_MAP_SELECT_ERROR(sock_errno()); + _PR_MD_MAP_SELECT_ERROR(sock_errno()); break; - } + } if (rv == 0) { - PR_SetError(PR_IO_TIMEOUT_ERROR, 0); - return -1; + PR_SetError(PR_IO_TIMEOUT_ERROR, 0); + return -1; } } } @@ -544,7 +590,7 @@ _PR_MD_SENDTO(PRFileDesc *fd, const void *buf, PRInt32 amount, PRIntn flags, } FD_ZERO(&wd); FD_SET(osfd, &wd); - if ((rv = select(osfd + 1, NULL, &wd, NULL, tvp)) == -1) { + if ((rv = _MD_SELECT(osfd + 1, NULL, &wd, NULL, tvp)) == -1) { #else if ( timeout == PR_INTERVAL_NO_TIMEOUT ) { @@ -555,21 +601,21 @@ _PR_MD_SENDTO(PRFileDesc *fd, const void *buf, PRInt32 amount, PRIntn flags, lTimeout = PR_IntervalToMilliseconds(timeout); } socks[0] = osfd; - if ((rv = select(socks, 0, 1, 0, lTimeout)) == -1) { + if ((rv = _MD_SELECT(socks, 0, 1, 0, lTimeout)) == -1) { #endif - _PR_MD_MAP_SELECT_ERROR(sock_errno()); + _PR_MD_MAP_SELECT_ERROR(sock_errno()); break; - } + } if (rv == 0) { - PR_SetError(PR_IO_TIMEOUT_ERROR, 0); - return -1; + PR_SetError(PR_IO_TIMEOUT_ERROR, 0); + return -1; } } else { - _PR_MD_MAP_SENDTO_ERROR(err); + _PR_MD_MAP_SENDTO_ERROR(err); return -1; - } + } } bytesSent += rv; if (fd->secret->nonblocking) @@ -592,7 +638,7 @@ _PR_MD_SENDTO(PRFileDesc *fd, const void *buf, PRInt32 amount, PRIntn flags, } FD_ZERO(&wd); FD_SET(osfd, &wd); - if ((rv = select( osfd + 1, NULL, &wd, NULL, tvp)) == -1) { + if ((rv = _MD_SELECT( osfd + 1, NULL, &wd, NULL, tvp)) == -1) { #else if ( timeout == PR_INTERVAL_NO_TIMEOUT ) { @@ -603,15 +649,15 @@ _PR_MD_SENDTO(PRFileDesc *fd, const void *buf, PRInt32 amount, PRIntn flags, lTimeout = PR_IntervalToMilliseconds(timeout); } socks[0] = osfd; - if ((rv = select( socks, 0, 1, 0, lTimeout)) == -1) { + if ((rv = _MD_SELECT( socks, 0, 1, 0, lTimeout)) == -1) { #endif - _PR_MD_MAP_SELECT_ERROR(sock_errno()); + _PR_MD_MAP_SELECT_ERROR(sock_errno()); break; - } + } if (rv == 0) { - PR_SetError(PR_IO_TIMEOUT_ERROR, 0); - return -1; + PR_SetError(PR_IO_TIMEOUT_ERROR, 0); + return -1; } } } @@ -640,20 +686,20 @@ _PR_MD_RECVFROM(PRFileDesc *fd, void *buf, PRInt32 amount, PRIntn flags, && (!fd->secret->nonblocking)) { #ifdef BSD_SELECT - if (timeout == PR_INTERVAL_NO_TIMEOUT) - { - tvp = NULL; - } - else - { - tv.tv_sec = PR_IntervalToSeconds(timeout); - tv.tv_usec = PR_IntervalToMicroseconds( - timeout - PR_SecondsToInterval(tv.tv_sec)); - tvp = &tv; - } - FD_ZERO(&rd); - FD_SET(osfd, &rd); - if ((rv = select(osfd + 1, &rd, NULL, NULL, tvp)) == -1) + if (timeout == PR_INTERVAL_NO_TIMEOUT) + { + tvp = NULL; + } + else + { + tv.tv_sec = PR_IntervalToSeconds(timeout); + tv.tv_usec = PR_IntervalToMicroseconds( + timeout - PR_SecondsToInterval(tv.tv_sec)); + tvp = &tv; + } + FD_ZERO(&rd); + FD_SET(osfd, &rd); + if ((rv = _MD_SELECT(osfd + 1, &rd, NULL, NULL, tvp)) == -1) #else if (timeout == PR_INTERVAL_NO_TIMEOUT) { @@ -664,14 +710,14 @@ _PR_MD_RECVFROM(PRFileDesc *fd, void *buf, PRInt32 amount, PRIntn flags, lTimeout = PR_IntervalToMilliseconds(timeout); } socks[0] = osfd; - if ((rv = select(socks, 1, 0, 0, lTimeout)) == -1) + if ((rv = _MD_SELECT(socks, 1, 0, 0, lTimeout)) == -1) #endif { - _PR_MD_MAP_SELECT_ERROR(sock_errno()); + _PR_MD_MAP_SELECT_ERROR(sock_errno()); return -1; } else if (rv == 0) { - PR_SetError(PR_IO_TIMEOUT_ERROR, 0); + PR_SetError(PR_IO_TIMEOUT_ERROR, 0); rv = -1; break; } @@ -681,7 +727,7 @@ _PR_MD_RECVFROM(PRFileDesc *fd, void *buf, PRInt32 amount, PRIntn flags, } else { - _PR_MD_MAP_RECVFROM_ERROR(err); + _PR_MD_MAP_RECVFROM_ERROR(err); break; } } @@ -726,12 +772,12 @@ _PR_MD_WRITEV(PRFileDesc *fd, const PRIOVec *iov, PRInt32 iov_size, PRIntervalTi PRInt32 _PR_MD_SHUTDOWN(PRFileDesc *fd, PRIntn how) { -PRInt32 rv; + PRInt32 rv; rv = shutdown(fd->secret->md.osfd, how); - if (rv < 0) - _PR_MD_MAP_SHUTDOWN_ERROR(sock_errno()); - return rv; + if (rv < 0) + _PR_MD_MAP_SHUTDOWN_ERROR(sock_errno()); + return rv; } PRStatus @@ -741,11 +787,11 @@ _PR_MD_GETSOCKNAME(PRFileDesc *fd, PRNetAddr *addr, PRUint32 *len) rv = getsockname((int)fd->secret->md.osfd, (struct sockaddr *)addr, (int *) len); if (rv==0) - return PR_SUCCESS; - else { - _PR_MD_MAP_GETSOCKNAME_ERROR(sock_errno()); - return PR_FAILURE; - } + return PR_SUCCESS; + else { + _PR_MD_MAP_GETSOCKNAME_ERROR(sock_errno()); + return PR_FAILURE; + } } PRStatus @@ -755,11 +801,11 @@ _PR_MD_GETPEERNAME(PRFileDesc *fd, PRNetAddr *addr, PRUint32 *len) rv = getpeername((int)fd->secret->md.osfd, (struct sockaddr *)addr, (int *) len); if (rv==0) - return PR_SUCCESS; - else { - _PR_MD_MAP_GETPEERNAME_ERROR(sock_errno()); - return PR_FAILURE; - } + return PR_SUCCESS; + else { + _PR_MD_MAP_GETPEERNAME_ERROR(sock_errno()); + return PR_FAILURE; + } } PRStatus @@ -769,11 +815,11 @@ _PR_MD_GETSOCKOPT(PRFileDesc *fd, PRInt32 level, PRInt32 optname, char* optval, rv = getsockopt((int)fd->secret->md.osfd, level, optname, optval, optlen); if (rv==0) - return PR_SUCCESS; - else { - _PR_MD_MAP_GETSOCKOPT_ERROR(sock_errno()); - return PR_FAILURE; - } + return PR_SUCCESS; + else { + _PR_MD_MAP_GETSOCKOPT_ERROR(sock_errno()); + return PR_FAILURE; + } } PRStatus @@ -783,11 +829,11 @@ _PR_MD_SETSOCKOPT(PRFileDesc *fd, PRInt32 level, PRInt32 optname, const char* op rv = setsockopt((int)fd->secret->md.osfd, level, optname, (char *) optval, optlen); if (rv==0) - return PR_SUCCESS; - else { - _PR_MD_MAP_SETSOCKOPT_ERROR(sock_errno()); - return PR_FAILURE; - } + return PR_SUCCESS; + else { + _PR_MD_MAP_SETSOCKOPT_ERROR(sock_errno()); + return PR_FAILURE; + } } void