On Tue, 2 Apr 2019 16:45:40 +0300 Slavomir Kaslev <kaslevs@xxxxxxxxxx> wrote: > +/* > + * Returns -1 on error. > + * or bytes of data read. > + */ > +static long direct_splice_data(struct tracecmd_recorder *recorder) > +{ > + struct pollfd pfd = { > + .fd = recorder->trace_fd, > + .events = POLLIN, > + }; > + long read; > + int ret; > + > + ret = poll(&pfd, 1, POLL_TIMEOUT_MS); > + if (ret < 0) > + return -1; > + > + if (!(pfd.revents | POLLIN)) > + return 0; Why the polling code, and not just block on splice? -- Steve > + > + read = splice(recorder->trace_fd, NULL, recorder->fd, NULL, > + recorder->pipe_size, recorder->trace_fd_flags); > + if (read < 0) { > + if (errno == EAGAIN || errno == EINTR) > + return 0; > + > + warning("recorder error in splice input"); > + return -1; > + } > + > + return read; > +} > +
![]() |