diff options
author | Stefan Metzmacher <metze@samba.org> | 2013-02-20 11:26:00 +0100 |
---|---|---|
committer | Jeremy Allison <jra@samba.org> | 2013-03-01 12:00:49 -0800 |
commit | ec9615c4fcbe15de1b0c16ccc6a52fa3ffb65b48 (patch) | |
tree | b2ff84a0813f7c887edd50afe774cc4913862fda | |
parent | 07e0427115f030b9b573b2d8a3a91b71b9b89eb6 (diff) | |
download | samba-ec9615c4fcbe15de1b0c16ccc6a52fa3ffb65b48.tar.gz samba-ec9615c4fcbe15de1b0c16ccc6a52fa3ffb65b48.tar.bz2 samba-ec9615c4fcbe15de1b0c16ccc6a52fa3ffb65b48.zip |
tevent: always go through epoll_update_event()
Signed-off-by: Stefan Metzmacher <metze@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
-rw-r--r-- | lib/tevent/tevent_epoll.c | 23 |
1 files changed, 14 insertions, 9 deletions
diff --git a/lib/tevent/tevent_epoll.c b/lib/tevent/tevent_epoll.c index f8b151d113..e68e37b45d 100644 --- a/lib/tevent/tevent_epoll.c +++ b/lib/tevent/tevent_epoll.c @@ -45,6 +45,10 @@ struct epoll_event_context { bool (*panic_fallback)(struct tevent_context *ev, bool replay); }; +#define EPOLL_ADDITIONAL_FD_FLAG_HAS_EVENT (1<<0) +#define EPOLL_ADDITIONAL_FD_FLAG_REPORT_ERROR (1<<1) +#define EPOLL_ADDITIONAL_FD_FLAG_GOT_ERROR (1<<2) + #ifdef TEST_PANIC_FALLBACK static int epoll_create_panic_fallback(struct epoll_event_context *epoll_ev, @@ -214,7 +218,7 @@ static int epoll_init_ctx(struct epoll_event_context *epoll_ev) return 0; } -static void epoll_add_event(struct epoll_event_context *epoll_ev, struct tevent_fd *fde); +static void epoll_update_event(struct epoll_event_context *epoll_ev, struct tevent_fd *fde); /* reopen the epoll handle when our pid changes @@ -246,7 +250,9 @@ static void epoll_check_reopen(struct epoll_event_context *epoll_ev) epoll_ev->pid = getpid(); epoll_ev->panic_state = &panic_triggered; for (fde=epoll_ev->ev->fd_events;fde;fde=fde->next) { - epoll_add_event(epoll_ev, fde); + fde->additional_flags &= ~EPOLL_ADDITIONAL_FD_FLAG_HAS_EVENT; + epoll_update_event(epoll_ev, fde); + if (panic_triggered) { if (caller_panic_state != NULL) { *caller_panic_state = true; @@ -257,10 +263,6 @@ static void epoll_check_reopen(struct epoll_event_context *epoll_ev) epoll_ev->panic_state = NULL; } -#define EPOLL_ADDITIONAL_FD_FLAG_HAS_EVENT (1<<0) -#define EPOLL_ADDITIONAL_FD_FLAG_REPORT_ERROR (1<<1) -#define EPOLL_ADDITIONAL_FD_FLAG_GOT_ERROR (1<<2) - /* add the epoll event to the given fd_event */ @@ -437,7 +439,7 @@ static int epoll_event_loop(struct epoll_event_context *epoll_ev, struct timeval * to match the select() behavior */ if (!(fde->additional_flags & EPOLL_ADDITIONAL_FD_FLAG_REPORT_ERROR)) { - epoll_del_event(epoll_ev, fde); + epoll_update_event(epoll_ev, fde); continue; } flags |= TEVENT_FD_READ; @@ -490,6 +492,7 @@ static int epoll_event_fd_destructor(struct tevent_fd *fde) struct tevent_context *ev = fde->event_ctx; struct epoll_event_context *epoll_ev = NULL; bool panic_triggered = false; + int flags = fde->flags; if (ev == NULL) { return tevent_common_fd_destructor(fde); @@ -511,7 +514,9 @@ static int epoll_event_fd_destructor(struct tevent_fd *fde) return tevent_common_fd_destructor(fde); } - epoll_del_event(epoll_ev, fde); + fde->flags = 0; + epoll_update_event(epoll_ev, fde); + fde->flags = flags; if (panic_triggered) { return tevent_common_fd_destructor(fde); } @@ -550,7 +555,7 @@ static struct tevent_fd *epoll_event_add_fd(struct tevent_context *ev, TALLOC_CT } epoll_ev->panic_state = NULL; - epoll_add_event(epoll_ev, fde); + epoll_update_event(epoll_ev, fde); return fde; } |