diff options
author | Andrew Tridgell <tridge@samba.org> | 2007-05-17 07:52:33 +0000 |
---|---|---|
committer | Gerald (Jerry) Carter <jerry@samba.org> | 2007-10-10 14:52:33 -0500 |
commit | ad1cde253e5938acf2c57458b5af04f32f45edbf (patch) | |
tree | 173b6a73c7dbf8bf4d7c9bde1c2691a5ad263602 /source4/lib/events/events_aio.c | |
parent | b5ae9019b0a0ae9b3b6593a0571e7ba474aa5ed2 (diff) | |
download | samba-ad1cde253e5938acf2c57458b5af04f32f45edbf.tar.gz samba-ad1cde253e5938acf2c57458b5af04f32f45edbf.tar.bz2 samba-ad1cde253e5938acf2c57458b5af04f32f45edbf.zip |
r22968: andrew bartlett pointed out that the parent process could add a fd to
the epoll context which would then appear in the children. To fix this
we need to check for pid changes in more places. Luckily on platforms
where we have epoll(), getpid() is very very cheap.
(This used to be commit 4f84e6d569f9c9d7dd902f4550735f3ce2d3b424)
Diffstat (limited to 'source4/lib/events/events_aio.c')
-rw-r--r-- | source4/lib/events/events_aio.c | 22 |
1 files changed, 11 insertions, 11 deletions
diff --git a/source4/lib/events/events_aio.c b/source4/lib/events/events_aio.c index e78487547f..ae5f597c18 100644 --- a/source4/lib/events/events_aio.c +++ b/source4/lib/events/events_aio.c @@ -103,10 +103,14 @@ static void epoll_add_event(struct aio_event_context *aio_ev, struct fd_event *f see http://junkcode.samba.org/ftp/unpacked/junkcode/epoll_fork.c for an demonstration of why this is needed */ -static void epoll_reopen(struct aio_event_context *aio_ev) +static void epoll_check_reopen(struct aio_event_context *aio_ev) { struct fd_event *fde; + if (aio_ev->pid == getpid()) { + return; + } + close(aio_ev->epoll_fd); aio_ev->epoll_fd = epoll_create(MAX_AIO_QUEUE_DEPTH); if (aio_ev->epoll_fd == -1) { @@ -131,16 +135,6 @@ static void epoll_add_event(struct aio_event_context *aio_ev, struct fd_event *f struct epoll_event event; if (aio_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 (aio_ev->pid != getpid()) { - epoll_reopen(aio_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 aio_event */ @@ -424,6 +418,8 @@ static struct fd_event *aio_event_add_fd(struct event_context *ev, TALLOC_CTX *m struct aio_event_context); struct fd_event *fde; + epoll_check_reopen(aio_ev); + fde = talloc(mem_ctx?mem_ctx:ev, struct fd_event); if (!fde) return NULL; @@ -468,6 +464,8 @@ static void aio_event_set_fd_flags(struct fd_event *fde, uint16_t flags) fde->flags = flags; + epoll_check_reopen(aio_ev); + epoll_change_event(aio_ev, fde); } @@ -485,6 +483,8 @@ static int aio_event_loop_once(struct event_context *ev) return 0; } + epoll_check_reopen(aio_ev); + return aio_event_loop(aio_ev, &tval); } |