qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Stefan Hajnoczi <stefanha@redhat.com>
To: Fam Zheng <famz@redhat.com>
Cc: Kevin Wolf <kwolf@redhat.com>,
	Paolo Bonzini <pbonzini@redhat.com>,
	qemu-devel@nongnu.org
Subject: Re: [Qemu-devel] [PATCH v3 7/7] poll-linux: Add timerfd support
Date: Thu, 16 Apr 2015 14:00:12 +0100	[thread overview]
Message-ID: <20150416130012.GE27070@stefanha-thinkpad.redhat.com> (raw)
In-Reply-To: <1429160256-27231-8-git-send-email-famz@redhat.com>

[-- Attachment #1: Type: text/plain, Size: 1005 bytes --]

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 #2: Type: application/pgp-signature, Size: 473 bytes --]

  reply	other threads:[~2015-04-16 13:00 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-04-16  4:57 [Qemu-devel] [PATCH v3 0/7] aio: Support epoll by introducing qemu_poll abstraction Fam Zheng
2015-04-16  4:57 ` [Qemu-devel] [PATCH v3 1/7] poll: Introduce QEMU Poll API Fam Zheng
2015-04-16  4:57 ` [Qemu-devel] [PATCH v3 2/7] posix-aio: Use QEMU poll interface Fam Zheng
2015-04-16  4:57 ` [Qemu-devel] [PATCH v3 3/7] poll: Add epoll implementation for qemu_poll Fam Zheng
2015-04-16  4:57 ` [Qemu-devel] [PATCH v3 4/7] main-loop: Replace qemu_poll_ns with qemu_poll Fam Zheng
2015-04-16  4:57 ` [Qemu-devel] [PATCH v3 5/7] tests: Add test case for qemu_poll Fam Zheng
2015-04-16  4:57 ` [Qemu-devel] [PATCH v3 6/7] poll-glib: Support ppoll Fam Zheng
2015-04-16  4:57 ` [Qemu-devel] [PATCH v3 7/7] poll-linux: Add timerfd support Fam Zheng
2015-04-16 13:00   ` Stefan Hajnoczi [this message]
2015-04-16 13:03 ` [Qemu-devel] [PATCH v3 0/7] aio: Support epoll by introducing qemu_poll abstraction Stefan Hajnoczi
2015-04-17  2:02   ` Fam Zheng
2015-04-20 10:36     ` Stefan Hajnoczi

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20150416130012.GE27070@stefanha-thinkpad.redhat.com \
    --to=stefanha@redhat.com \
    --cc=famz@redhat.com \
    --cc=kwolf@redhat.com \
    --cc=pbonzini@redhat.com \
    --cc=qemu-devel@nongnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).