MCPcopy Create free account
hub / github.com/F-Stack/f-stack / pipe_clone_write_buffer

Function pipe_clone_write_buffer

freebsd/kern/sys_pipe.c:935–968  ·  view source on GitHub ↗

* In the case of a signal, the writing process might go away. This * code copies the data into the circular buffer so that the source * pages can be freed without loss of data. */

Source from the content-addressed store, hash-verified

933 * pages can be freed without loss of data.
934 */
935static void
936pipe_clone_write_buffer(struct pipe *wpipe)
937{
938 struct uio uio;
939 struct iovec iov;
940 int size;
941 int pos;
942
943 PIPE_LOCK_ASSERT(wpipe, MA_OWNED);
944 KASSERT((wpipe->pipe_state & PIPE_DIRECTW) != 0,
945 ("%s: PIPE_DIRECTW not set on %p", __func__, wpipe));
946
947 size = wpipe->pipe_pages.cnt;
948 pos = wpipe->pipe_pages.pos;
949 wpipe->pipe_pages.cnt = 0;
950
951 wpipe->pipe_buffer.in = size;
952 wpipe->pipe_buffer.out = 0;
953 wpipe->pipe_buffer.cnt = size;
954
955 PIPE_UNLOCK(wpipe);
956 iov.iov_base = wpipe->pipe_buffer.buffer;
957 iov.iov_len = size;
958 uio.uio_iov = &iov;
959 uio.uio_iovcnt = 1;
960 uio.uio_offset = 0;
961 uio.uio_resid = size;
962 uio.uio_segflg = UIO_SYSSPACE;
963 uio.uio_rw = UIO_READ;
964 uio.uio_td = curthread;
965 uiomove_fromphys(wpipe->pipe_pages.ms, pos, size, &uio);
966 PIPE_LOCK(wpipe);
967 pipe_destroy_write_buffer(wpipe);
968}
969
970/*
971 * This implements the pipe buffer write mechanism. Note that only

Callers 1

pipe_direct_writeFunction · 0.85

Calls 2

uiomove_fromphysFunction · 0.50

Tested by

no test coverage detected