PR_ASSERT(_PR_TRI_UNKNOWN != fd->secret->inheritable); if (fd->secret->nonblocking || fd->secret->inheritable) {
if (_NT_USE_NB_IO(fd)) {
_PR_MD_FAST_ACCEPT(PRFileDesc *fd, PRNetAddr *raddr, PRUint32 *rlen,              PRIntervalTime timeout, PRBool fast,               _PR_AcceptTimeoutCallback callback, void *callbackArg){    PRInt32 osfd = fd->secret->md.osfd;    PRThread *me = _PR_MD_CURRENT_THREAD();    SOCKET accept_sock;    int bytes;    PRNetAddr *Laddr;    PRNetAddr *Raddr;    PRUint32 llen, err;    int rv;    PR_ASSERT(_PR_TRI_UNKNOWN != fd->secret->inheritable);    if (fd->secret->nonblocking || fd->secret->inheritable) {        if (!fd->secret->md.io_model_committed) {            rv = _md_MakeNonblock((HANDLE)osfd);            PR_ASSERT(0 != rv);            fd->secret->md.io_model_committed = PR_TRUE;        }        /*         * The accepted socket inherits the nonblocking and         * inheritable (HANDLE_FLAG_INHERIT) attributes of         * the listening socket.         */        accept_sock = _nt_nonblock_accept(fd, (struct sockaddr *)raddr, rlen, timeout);        if (!fd->secret->nonblocking) {            u_long zero = 0;            rv = ioctlsocket(accept_sock, FIONBIO, &zero);            PR_ASSERT(0 == rv);        }        return accept_sock;    }    if (me->io_suspended) {        PR_SetError(PR_INVALID_STATE_ERROR, 0);        return -1;    }    if (!fd->secret->md.io_model_committed) {        rv = _md_Associate((HANDLE)osfd);        PR_ASSERT(0 != rv);        fd->secret->md.io_model_committed = PR_TRUE;    }    if (!me->md.acceptex_buf) {        me->md.acceptex_buf = PR_MALLOC(2*INET_ADDR_PADDED);        if (!me->md.acceptex_buf) {            PR_SetError(PR_OUT_OF_MEMORY_ERROR, 0);            return -1;        }    }    accept_sock = _md_get_recycled_socket();    if (accept_sock == INVALID_SOCKET)        return -1;    memset(&(me->md.overlapped.overlapped), 0, sizeof(OVERLAPPED));	if (_native_threads_only)		me->md.overlapped.overlapped.hEvent = me->md.thr_event;    _PR_THREAD_LOCK(me);	if (_PR_PENDING_INTERRUPT(me)) {		me->flags &= ~_PR_INTERRUPT;		PR_SetError(PR_PENDING_INTERRUPT_ERROR, 0);    	_PR_THREAD_UNLOCK(me);		return -1;	}    me->io_pending = PR_TRUE;    me->state = _PR_IO_WAIT;    _PR_THREAD_UNLOCK(me);    me->io_fd = osfd;    rv = AcceptEx((SOCKET)osfd,                  accept_sock,                  me->md.acceptex_buf,                  0,                  INET_ADDR_PADDED,                  INET_ADDR_PADDED,                  &bytes,                  &(me->md.overlapped.overlapped));    if ( (rv == 0) && ((err = GetLastError()) != ERROR_IO_PENDING))  {        /* Argh! The IO failed */		_PR_THREAD_LOCK(me);		me->io_pending = PR_FALSE;		me->state = _PR_RUNNING;		if (_PR_PENDING_INTERRUPT(me)) {			me->flags &= ~_PR_INTERRUPT;			PR_SetError(PR_PENDING_INTERRUPT_ERROR, 0);			_PR_THREAD_UNLOCK(me);			return -1;		}		_PR_THREAD_UNLOCK(me);		_PR_MD_MAP_ACCEPTEX_ERROR(err);        return -1;    }    if (_native_threads_only && rv) {        _native_thread_io_nowait(me, rv, bytes);    } else if (_NT_IO_WAIT(me, timeout) == PR_FAILURE) {        PR_ASSERT(0);        return -1;    }    PR_ASSERT(me->io_pending == PR_FALSE || me->io_suspended == PR_TRUE);    if (me->io_suspended) {        if (_PR_PENDING_INTERRUPT(me)) {            me->flags &= ~_PR_INTERRUPT;            PR_SetError(PR_PENDING_INTERRUPT_ERROR, 0);        } else {            PR_SetError(PR_IO_TIMEOUT_ERROR, 0);        }        return -1;    }    if (me->md.blocked_io_status == 0) {		_PR_MD_MAP_ACCEPTEX_ERROR(me->md.blocked_io_error);        return -1;    }    if (!fast)        _PR_MD_UPDATE_ACCEPT_CONTEXT((SOCKET)accept_sock, (SOCKET)osfd);    /* IO is done */    GetAcceptExSockaddrs(            me->md.acceptex_buf,            0,            INET_ADDR_PADDED,            INET_ADDR_PADDED,            (LPSOCKADDR *)&(Laddr),            &llen,            (LPSOCKADDR *)&(Raddr),            (unsigned int *)rlen);    if (raddr != NULL)        memcpy((char *)raddr, (char *)&Raddr->inet, *rlen);    PR_ASSERT(me->io_pending == PR_FALSE);    return accept_sock;}