PR_ASSERT(_PR_TRI_UNKNOWN != fd->secret->inheritable); if (fd->secret->nonblocking || fd->secret->inheritable) {
if (_NT_USE_NB_IO(fd)) {
_PR_MD_SEND(PRFileDesc *fd, const void *buf, PRInt32 amount, PRIntn flags,            PRIntervalTime timeout){    PRInt32 osfd = fd->secret->md.osfd;    PRThread *me = _PR_MD_CURRENT_THREAD();    int bytes;    int rv, err;    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;        }        return _nt_nonblock_send(fd, (char *)buf, amount, timeout);    }    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;    }    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 = WriteFile((HANDLE)osfd,                   buf,                    amount,                   &bytes,                   &(me->md.overlapped.overlapped));    if ( (rv == 0) && ((err = GetLastError()) != ERROR_IO_PENDING) ) {    	_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_WRITE_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_WRITE_ERROR(me->md.blocked_io_error);        return -1;    }    PR_ASSERT(me->io_pending == PR_FALSE);    return me->md.blocked_io_bytes;}