commit ff47022487821209766a1ed2b881c9584ba08120 from: Stefan Sperling via: Thomas Adam date: Thu May 19 13:34:05 2022 UTC revert "Skip poll(2) if an imsgbuf has a non-empty read buffer" imsg_read() will call recvmsg() on the file descriptor regardless of the read buffer's state, so we should ensure that data is ready. The read buffer is used by imsg_get(), not imsg_read(). We already call imsg_get() before imsg_read(), and call the latter only if imsg_get() returns zero. commit - 3e54812463cc8a33236c16a18d1361597e516d71 commit + ff47022487821209766a1ed2b881c9584ba08120 blob - d0da0d1326d22a856516386bcc38b06f9e55d415 blob + c0b028f2df10a4790b2d55637533cce65b42ab06 --- lib/privsep.c +++ lib/privsep.c @@ -93,15 +93,9 @@ read_imsg(struct imsgbuf *ibuf) const struct got_error *err; size_t n; - /* - * There is no imsg API function to tell us whether the - * read buffer still contains pending data :-( - */ - if (ibuf->r.wpos < IMSG_HEADER_SIZE) { - err = poll_fd(ibuf->fd, POLLIN, INFTIM); - if (err) - return err; - } + err = poll_fd(ibuf->fd, POLLIN, INFTIM); + if (err) + return err; n = imsg_read(ibuf); if (n == -1) {