commit c9b75c7bd7036a6895bbc3eba2ed0369238ebab4 from: Stefan Sperling date: Thu May 19 07:31:57 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 - 2ab714554f1fd2273c9705450cf192dabb4f6b9d commit + c9b75c7bd7036a6895bbc3eba2ed0369238ebab4 blob - 135b8b683601bf61cba1c6e83ed9d36da871f90d blob + 782f94ad26528e54d59fa5855bd1a0a4f674588b --- lib/privsep.c +++ lib/privsep.c @@ -94,15 +94,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) {