From 4f82b2a81688a862354674d6304cf572122a280b Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Fri, 1 Mar 2013 16:43:35 +0100 Subject: [PATCH] tevent: revalidate fde->flags after poll() This is important to avoid races between threads if the poll_mt backend is used. Signed-off-by: Stefan Metzmacher --- lib/tevent/tevent_poll.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/lib/tevent/tevent_poll.c b/lib/tevent/tevent_poll.c index 867d951ee1b1..aa4c50c0c5ec 100644 --- a/lib/tevent/tevent_poll.c +++ b/lib/tevent/tevent_poll.c @@ -594,6 +594,12 @@ static int poll_event_loop_poll(struct tevent_context *ev, if (pfd->revents & POLLOUT) { flags |= TEVENT_FD_WRITE; } + /* + * Note that fde->flags could be changed when using + * the poll_mt backend together with threads, + * that why we need to check pfd->revents and fde->flags + */ + flags &= fde->flags; if (flags != 0) { fde->handler(ev, fde, flags, fde->private_data); return 0; -- 2.34.1