qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Qemu-devel] [PATCH v3 7/7] poll-linux: Add timerfd support


From: Stefan Hajnoczi
Subject: Re: [Qemu-devel] [PATCH v3 7/7] poll-linux: Add timerfd support
Date: Thu, 16 Apr 2015 14:00:12 +0100
User-agent: Mutt/1.5.23 (2014-03-12)

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).

Attachment: pgpB5ts_PS48P.pgp
Description: PGP signature


reply via email to

[Prev in Thread] Current Thread [Next in Thread]