summaryrefslogtreecommitdiff
path: root/source4/lib/events/events_epoll.c
diff options
context:
space:
mode:
Diffstat (limited to 'source4/lib/events/events_epoll.c')
-rw-r--r--source4/lib/events/events_epoll.c22
1 files changed, 11 insertions, 11 deletions
diff --git a/source4/lib/events/events_epoll.c b/source4/lib/events/events_epoll.c
index 5b6266fb49..413925357e 100644
--- a/source4/lib/events/events_epoll.c
+++ b/source4/lib/events/events_epoll.c
@@ -102,10 +102,14 @@ static void epoll_add_event(struct epoll_event_context *epoll_ev, struct fd_even
see http://junkcode.samba.org/ftp/unpacked/junkcode/epoll_fork.c for an
demonstration of why this is needed
*/
-static void epoll_reopen(struct epoll_event_context *epoll_ev)
+static void epoll_check_reopen(struct epoll_event_context *epoll_ev)
{
struct fd_event *fde;
+ if (epoll_ev->pid == getpid()) {
+ return;
+ }
+
close(epoll_ev->epoll_fd);
epoll_ev->epoll_fd = epoll_create(64);
if (epoll_ev->epoll_fd == -1) {
@@ -131,16 +135,6 @@ static void epoll_add_event(struct epoll_event_context *epoll_ev, struct fd_even
if (epoll_ev->epoll_fd == -1) return;
- /* during an add event we need to check if our pid has changed
- and re-open the epoll socket. Note that we don't need to do this
- for other epoll changes */
- if (epoll_ev->pid != getpid()) {
- epoll_reopen(epoll_ev);
- /* the current event gets added in epoll_reopen(), so
- we can return here */
- return;
- }
-
fde->additional_flags &= ~EPOLL_ADDITIONAL_FD_FLAG_REPORT_ERROR;
/* if we don't want events yet, don't add an epoll_event */
@@ -373,6 +367,8 @@ static struct fd_event *epoll_event_add_fd(struct event_context *ev, TALLOC_CTX
struct epoll_event_context);
struct fd_event *fde;
+ epoll_check_reopen(epoll_ev);
+
fde = talloc(mem_ctx?mem_ctx:ev, struct fd_event);
if (!fde) return NULL;
@@ -417,6 +413,8 @@ static void epoll_event_set_fd_flags(struct fd_event *fde, uint16_t flags)
fde->flags = flags;
+ epoll_check_reopen(epoll_ev);
+
epoll_change_event(epoll_ev, fde);
}
@@ -434,6 +432,8 @@ static int epoll_event_loop_once(struct event_context *ev)
return 0;
}
+ epoll_check_reopen(epoll_ev);
+
return epoll_event_loop(epoll_ev, &tval);
}