static PRInt32 filtermethod_emulate_sendfile(PRFileDesc *fd, PRSendFileData *data, PRTransmitFileFlags flags, PRIntervalTime timeout) { // XXX Uses mmap(), so it can exhaust address space. Roll our own? // XXX How can we tell NSFC to cache file content instead of the fd? // XXX Maybe if (filter_has_sendfile(sn->csd)) ... ? return PR_EmulateSendFile(fd, data, flags, timeout); }
static PRInt32 PR_CALLBACK SocketSendFile( PRFileDesc *sd, PRSendFileData *sfd, PRTransmitFileFlags flags, PRIntervalTime timeout) { PRInt32 rv; PRThread *me = _PR_MD_CURRENT_THREAD(); if (_PR_PENDING_INTERRUPT(me)) { me->flags &= ~_PR_INTERRUPT; PR_SetError(PR_PENDING_INTERRUPT_ERROR, 0); return -1; } if (_PR_IO_PENDING(me)) { PR_SetError(PR_IO_PENDING_ERROR, 0); return -1; } /* The socket must be in blocking mode. */ if (sd->secret->nonblocking) { PR_SetError(PR_INVALID_ARGUMENT_ERROR, 0); return -1; } #if defined(WINNT) rv = _PR_MD_SENDFILE(sd, sfd, flags, timeout); if ((rv >= 0) && (flags == PR_TRANSMITFILE_CLOSE_SOCKET)) { /* * This should be kept the same as SocketClose, except * that _PR_MD_CLOSE_SOCKET(sd->secret->md.osfd) should * not be called because the socket will be recycled. */ PR_FreeFileDesc(sd); } #else rv = PR_EmulateSendFile(sd, sfd, flags, timeout); #endif /* WINNT */ return rv; }