From: Paolo Bonzini <pbonzini@redhat.com>
To: qemu-devel@nongnu.org
Cc: qemu-block@nongnu.org, famz@redhat.com, kwolf@redhat.com
Subject: [Qemu-devel] [PATCH 2/2] aio-posix: simplify aio_epoll_update
Date: Mon, 7 Nov 2016 10:33:34 +0100 [thread overview]
Message-ID: <1478511214-31045-3-git-send-email-pbonzini@redhat.com> (raw)
In-Reply-To: <1478511214-31045-1-git-send-email-pbonzini@redhat.com>
Extract common code out of the "if".
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
---
aio-posix.c | 23 ++++++++---------------
1 file changed, 8 insertions(+), 15 deletions(-)
diff --git a/aio-posix.c b/aio-posix.c
index ec908f7..d54553d 100644
--- a/aio-posix.c
+++ b/aio-posix.c
@@ -81,29 +81,22 @@ static void aio_epoll_update(AioContext *ctx, AioHandler *node, bool is_new)
{
struct epoll_event event;
int r;
+ int ctl;
if (!ctx->epoll_enabled) {
return;
}
if (!node->pfd.events) {
- r = epoll_ctl(ctx->epollfd, EPOLL_CTL_DEL, node->pfd.fd, &event);
- if (r) {
- aio_epoll_disable(ctx);
- }
+ ctl = EPOLL_CTL_DEL;
} else {
event.data.ptr = node;
event.events = epoll_events_from_pfd(node->pfd.events);
- if (is_new) {
- r = epoll_ctl(ctx->epollfd, EPOLL_CTL_ADD, node->pfd.fd, &event);
- if (r) {
- aio_epoll_disable(ctx);
- }
- } else {
- r = epoll_ctl(ctx->epollfd, EPOLL_CTL_MOD, node->pfd.fd, &event);
- if (r) {
- aio_epoll_disable(ctx);
- }
- }
+ ctl = is_new ? EPOLL_CTL_ADD : EPOLL_CTL_MOD;
+ }
+
+ r = epoll_ctl(ctx->epollfd, ctl, node->pfd.fd, &event);
+ if (r) {
+ aio_epoll_disable(ctx);
}
}
--
2.7.4
next prev parent reply other threads:[~2016-11-07 9:33 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-11-07 9:33 [Qemu-devel] [PATCH for-2.8 0/2] aio-posix: epoll cleanups Paolo Bonzini
2016-11-07 9:33 ` [Qemu-devel] [PATCH 1/2] aio-posix: avoid NULL pointer dereference in aio_epoll_update Paolo Bonzini
2016-11-07 14:58 ` [Qemu-devel] [Qemu-block] " Stefan Hajnoczi
2016-11-07 15:35 ` Paolo Bonzini
2016-11-07 9:33 ` Paolo Bonzini [this message]
2016-11-07 15:01 ` [Qemu-devel] [Qemu-block] [PATCH 2/2] aio-posix: simplify aio_epoll_update Stefan Hajnoczi
2016-11-07 10:08 ` [Qemu-devel] [PATCH for-2.8 0/2] aio-posix: epoll cleanups Fam Zheng
-- strict thread matches above, loose matches on Subject: below --
2016-11-08 13:55 [Qemu-devel] [PATCH for-2.8 v2 " Paolo Bonzini
2016-11-08 13:55 ` [Qemu-devel] [PATCH 2/2] aio-posix: simplify aio_epoll_update Paolo Bonzini
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=1478511214-31045-3-git-send-email-pbonzini@redhat.com \
--to=pbonzini@redhat.com \
--cc=famz@redhat.com \
--cc=kwolf@redhat.com \
--cc=qemu-block@nongnu.org \
--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).