diff options
author | Jeremy Allison <jra@samba.org> | 2013-02-27 10:18:44 -0800 |
---|---|---|
committer | Jeremy Allison <jra@samba.org> | 2013-03-01 11:59:59 -0800 |
commit | 5ca69148844e2f8940b571aef0812e85e08b7cc5 (patch) | |
tree | 5851b178ff424f0fe36dd8f169394d0c89044307 /lib/tevent | |
parent | b53c704a34abca0ad69ae9a0dbb0db6a0a71043b (diff) | |
download | samba-5ca69148844e2f8940b571aef0812e85e08b7cc5.tar.gz samba-5ca69148844e2f8940b571aef0812e85e08b7cc5.tar.xz samba-5ca69148844e2f8940b571aef0812e85e08b7cc5.zip |
tevent: Fix multiple handler on the same fd bug in the tevent select backend.
When we're deciding what handlers to call in the select backend,
we didn't take into account the fact that the same fd may have
been added into the read FD_SET and the write FD_SET but with
different handlers.
We must match on both the file descriptor and the flags requested
before calling the handler.
Signed-off-by: Jeremy Allison <jra@samba.org>
Reviewed-by: Stefan Metzmacher <metze@samba.org>
Diffstat (limited to 'lib/tevent')
-rw-r--r-- | lib/tevent/tevent_select.c | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/lib/tevent/tevent_select.c b/lib/tevent/tevent_select.c index ffb0d18c2e..24032631f8 100644 --- a/lib/tevent/tevent_select.c +++ b/lib/tevent/tevent_select.c @@ -210,8 +210,12 @@ static int select_event_loop_select(struct select_event_context *select_ev, stru for (fde = select_ev->ev->fd_events; fde; fde = fde->next) { uint16_t flags = 0; - if (FD_ISSET(fde->fd, &r_fds)) flags |= TEVENT_FD_READ; - if (FD_ISSET(fde->fd, &w_fds)) flags |= TEVENT_FD_WRITE; + if (FD_ISSET(fde->fd, &r_fds) && (fde->flags & TEVENT_FD_READ)) { + flags |= TEVENT_FD_READ; + } + if (FD_ISSET(fde->fd, &w_fds) && (fde->flags & TEVENT_FD_WRITE)) { + flags |= TEVENT_FD_WRITE; + } if (flags) { fde->handler(select_ev->ev, fde, flags, fde->private_data); break; |