On Thu, Apr 16, 2015 at 12:57:36PM +0800, Fam Zheng wrote:
> +static int qemu_poll_timerfd(QEMUPoll *qpoll, int64_t timeout_ns)
> +{
> + int r;
> + struct itimerspec its = { { 0 } };
> +
> + if (timeout_ns > 0) {
> + its.it_value.tv_sec = timeout_ns / 1000000000LL;
> + its.it_value.tv_nsec = timeout_ns % 1000000000LL;
> + }
> +
> + r = timerfd_settime(qpoll->timerfd, 0, &its, NULL);
Can't hurt to put a comment here:
/* The timer must be set even when there is no timeout so the readable
* timerfd is cleared (we never call read(2) on it).
*/
> + if (r) {
> + struct pollfd fd = {
> + .fd = qpoll->epollfd,
> + .events = POLLIN | POLLOUT | POLLERR | POLLHUP,
> + };
> + perror("timerfd_settime");
> + abort();
> + r = ppoll(&fd, 1, &its.it_value, NULL);
Please remove the dead code.
In fact, there is no reasonable error for timerfd_settime(). It should
never fail, I'd be happy with just assert(r == 0).
pgpkl3wGQcQv8.pgp
Description: PGP signature
