if (((err = sock_errno()) == EWOULDBLOCK) && (!fd->secret->nonblocking)) { #ifdef BSD_SELECT if ((rv = _MD_SELECT(osfd + 1, &rd, NULL, NULL,NULL)) == -1) { #else if ((rv = _MD_SELECT(socks, 1, 0, 0, -1)) == -1) { #endif _PR_MD_MAP_SELECT_ERROR(sock_errno()); break; } } else { _PR_MD_MAP_ACCEPT_ERROR(err);
if (fd->secret->nonblocking) {
_MD_Accept(PRFileDesc *fd, PRNetAddr *raddr, PRUint32 *rlen,              PRIntervalTime timeout ){    PRInt32 osfd = fd->secret->md.osfd;    PRInt32 rv, err;#ifdef BSD_SELECT    fd_set rd;    struct timeval tv, *tvp;    FD_ZERO(&rd);    FD_SET(osfd, &rd);#else    int socks[1];    socks[0] = osfd; #endif    if (timeout == PR_INTERVAL_NO_TIMEOUT)     {        while ((rv = accept(osfd, (struct sockaddr *) raddr, (int *) rlen)) == -1)         {            if (((err = sock_errno()) == EWOULDBLOCK)                 && (!fd->secret->nonblocking))            {#ifdef BSD_SELECT                if ((rv = _MD_SELECT(osfd + 1, &rd, NULL, NULL,NULL)) == -1) {#else                if ((rv = _MD_SELECT(socks, 1, 0, 0, -1)) == -1) {#endif                    _PR_MD_MAP_SELECT_ERROR(sock_errno());                    break;                }             }             else {                _PR_MD_MAP_ACCEPT_ERROR(err);                break;            }        }        return(rv);    }     else if (timeout == PR_INTERVAL_NO_WAIT)     {        if ((rv = accept(osfd, (struct sockaddr *) raddr, (int *) rlen)) == -1)        {            if (((err = sock_errno()) == EWOULDBLOCK)                 && (!fd->secret->nonblocking))            {                PR_SetError(PR_IO_TIMEOUT_ERROR, 0);            }            else            {                _PR_MD_MAP_ACCEPT_ERROR(err);            }        }        return(rv);    }     else     {retry:        if ((rv = accept(osfd, (struct sockaddr *) raddr, (int *) rlen)) == -1)         {            if (((err = sock_errno()) == EWOULDBLOCK)                 && (!fd->secret->nonblocking))            {#ifdef BSD_SELECT                tv.tv_sec = PR_IntervalToSeconds(timeout);                tv.tv_usec = PR_IntervalToMicroseconds(timeout - PR_SecondsToInterval(tv.tv_sec));                tvp = &tv;                rv = _MD_SELECT(osfd + 1, &rd, NULL, NULL, tvp);#else                long lTimeout = PR_IntervalToMilliseconds(timeout);                 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);                    rv = -1;                } else {                    _PR_MD_MAP_SELECT_ERROR(sock_errno());                }            } else {                _PR_MD_MAP_ACCEPT_ERROR(err);            }        }    }    return(rv);} /* end _MD_Accept() */