aio-posix: simplify aio_epoll_update
Extract common code out of the "if". Reviewed-by: Fam Zheng <famz@redhat.com> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com> Message-id: 20161108135524.25927-3-pbonzini@redhat.com Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
This commit is contained in:
parent
36173ec5f1
commit
35dd66e23c
23
aio-posix.c
23
aio-posix.c
@ -81,29 +81,22 @@ static void aio_epoll_update(AioContext *ctx, AioHandler *node, bool is_new)
|
|||||||
{
|
{
|
||||||
struct epoll_event event;
|
struct epoll_event event;
|
||||||
int r;
|
int r;
|
||||||
|
int ctl;
|
||||||
|
|
||||||
if (!ctx->epoll_enabled) {
|
if (!ctx->epoll_enabled) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (!node->pfd.events) {
|
if (!node->pfd.events) {
|
||||||
r = epoll_ctl(ctx->epollfd, EPOLL_CTL_DEL, node->pfd.fd, &event);
|
ctl = EPOLL_CTL_DEL;
|
||||||
if (r) {
|
|
||||||
aio_epoll_disable(ctx);
|
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
event.data.ptr = node;
|
event.data.ptr = node;
|
||||||
event.events = epoll_events_from_pfd(node->pfd.events);
|
event.events = epoll_events_from_pfd(node->pfd.events);
|
||||||
if (is_new) {
|
ctl = is_new ? EPOLL_CTL_ADD : EPOLL_CTL_MOD;
|
||||||
r = epoll_ctl(ctx->epollfd, EPOLL_CTL_ADD, node->pfd.fd, &event);
|
}
|
||||||
if (r) {
|
|
||||||
aio_epoll_disable(ctx);
|
r = epoll_ctl(ctx->epollfd, ctl, node->pfd.fd, &event);
|
||||||
}
|
if (r) {
|
||||||
} else {
|
aio_epoll_disable(ctx);
|
||||||
r = epoll_ctl(ctx->epollfd, EPOLL_CTL_MOD, node->pfd.fd, &event);
|
|
||||||
if (r) {
|
|
||||||
aio_epoll_disable(ctx);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user