[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).
pgpB5ts_PS48P.pgp
Description: PGP signature
- [Qemu-devel] [PATCH v3 0/7] aio: Support epoll by introducing qemu_poll abstraction, Fam Zheng, 2015/04/16
- [Qemu-devel] [PATCH v3 1/7] poll: Introduce QEMU Poll API, Fam Zheng, 2015/04/16
- [Qemu-devel] [PATCH v3 3/7] poll: Add epoll implementation for qemu_poll, Fam Zheng, 2015/04/16
- [Qemu-devel] [PATCH v3 2/7] posix-aio: Use QEMU poll interface, Fam Zheng, 2015/04/16
- [Qemu-devel] [PATCH v3 4/7] main-loop: Replace qemu_poll_ns with qemu_poll, Fam Zheng, 2015/04/16
- [Qemu-devel] [PATCH v3 5/7] tests: Add test case for qemu_poll, Fam Zheng, 2015/04/16
- [Qemu-devel] [PATCH v3 6/7] poll-glib: Support ppoll, Fam Zheng, 2015/04/16
- [Qemu-devel] [PATCH v3 7/7] poll-linux: Add timerfd support, Fam Zheng, 2015/04/16
- Re: [Qemu-devel] [PATCH v3 7/7] poll-linux: Add timerfd support,
Stefan Hajnoczi <=
- Re: [Qemu-devel] [PATCH v3 0/7] aio: Support epoll by introducing qemu_poll abstraction, Stefan Hajnoczi, 2015/04/16