Lines Matching refs:fd

41 status_t FdBuffer::read(int fd, int64_t timeout) {
42 struct pollfd pfds = {.fd = fd, .events = POLLIN};
45 fcntl(fd, F_SETFL, fcntl(fd, F_GETFL, 0) | O_NONBLOCK);
74 ssize_t amt = ::read(fd, mBuffer.writeBuffer(), mBuffer.currentToWrite());
79 VLOG("Fail to read %d: %s", fd, strerror(errno));
83 VLOG("Reached EOF of fd=%d", fd);
94 status_t FdBuffer::readFully(int fd) {
107 TEMP_FAILURE_RETRY(::read(fd, mBuffer.writeBuffer(), mBuffer.currentToWrite()));
109 VLOG("Fail to read %d: %s", fd, strerror(errno));
123 status_t FdBuffer::readProcessedDataInStream(int fd, unique_fd toFd, unique_fd fromFd,
126 {.fd = fd, .events = POLLIN},
127 {.fd = toFd.get(), .events = POLLOUT},
128 {.fd = fromFd.get(), .events = POLLIN},
134 fcntl(fd, F_SETFL, fcntl(fd, F_GETFL, 0) | O_NONBLOCK);
138 // A circular buffer holds data read from fd and writes to parsing process
173 VLOG("fd %d is sysfs, ignore its POLLERR return value", fd);
176 VLOG("fd[%d]=%d returns error events: %s", i, fd, strerror(errno));
181 // read from fd
182 if (cirSize != BUFFER_SIZE && pfds[0].fd != -1) {
185 amt = ::read(fd, cirBuf + rpos, BUFFER_SIZE - rpos);
187 amt = ::read(fd, cirBuf + rpos, wpos - rpos);
191 VLOG("Fail to read fd %d: %s", fd, strerror(errno));
195 VLOG("Reached EOF of input file %d", fd);
196 pfds[0].fd = -1; // reach EOF so don't have to poll pfds[0].
204 if (cirSize > 0 && pfds[1].fd != -1) {
222 // if buffer is empty and fd is closed, close write fd.
223 if (cirSize == 0 && pfds[0].fd == -1 && pfds[1].fd != -1) {
226 pfds[1].fd = -1;