Use pipe_direct_write() optimization only if the data is in process' memory.

This fixes sending data through pipe from the kernel.

Fix suggested by:	rwatson
This commit is contained in:
Pawel Jakub Dawidek 2006-12-19 12:52:22 +00:00
parent 5eccbe45a7
commit ce0d4ed4c2
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=165347

View File

@ -1074,8 +1074,9 @@ pipe_write(fp, uio, active_cred, flags, td)
* The direct write mechanism will detect the reader going
* away on us.
*/
if ((uio->uio_iov->iov_len >= PIPE_MINDIRECT) &&
(wpipe->pipe_buffer.size >= PIPE_MINDIRECT) &&
if (uio->uio_segflg == UIO_USERSPACE &&
uio->uio_iov->iov_len >= PIPE_MINDIRECT &&
wpipe->pipe_buffer.size >= PIPE_MINDIRECT &&
(fp->f_flag & FNONBLOCK) == 0) {
pipeunlock(wpipe);
error = pipe_direct_write(wpipe, uio);