diff options
author | Jeremy Allison <jra@samba.org> | 2011-06-03 12:31:11 -0700 |
---|---|---|
committer | Karolin Seeger <kseeger@samba.org> | 2011-06-07 20:04:16 +0200 |
commit | 9546457783e89514d5be5a7a168f19152ffa6a21 (patch) | |
tree | b4b3630cfccba50a6cf6c82894c6966ea66aedff | |
parent | 4848637999bc2d1245936282d03c07610454c761 (diff) | |
download | samba-9546457783e89514d5be5a7a168f19152ffa6a21.tar.gz |
Fix the poll() backend to correctly respond to POLLHUP|POLLERR returns on a fd selected for TEVENT_FD_WRITE only.
Don't trigger the write handler and remove the POLLOUT flag for this fd. Report errors on TEVENT_FD_READ requests only.
Metze please check !
Jeremy.
Autobuild-User: Jeremy Allison <jra@samba.org>
Autobuild-Date: Fri Jun 3 22:53:52 CEST 2011 on sn-devel-104
(cherry picked from commit dbcdf3e39c359241b743a9455ae695e14a30caa9)
(cherry picked from commit 4da2f8a8c578568d1e9a4770166c46240fce6664)
-rw-r--r-- | lib/tevent/tevent_poll.c | 14 |
1 files changed, 13 insertions, 1 deletions
diff --git a/lib/tevent/tevent_poll.c b/lib/tevent/tevent_poll.c index 712255b3732..0b782e99bb8 100644 --- a/lib/tevent/tevent_poll.c +++ b/lib/tevent/tevent_poll.c @@ -233,7 +233,19 @@ static int poll_event_loop_poll(struct tevent_context *ev, pfd = &poll_ev->fds[pfd_idx]; - if (pfd->revents & (POLLIN|POLLHUP|POLLERR)) { + if (pfd->revents & (POLLHUP|POLLERR)) { + /* If we only wait for TEVENT_FD_WRITE, we + should not tell the event handler about it, + and remove the writable flag, as we only + report errors when waiting for read events + to match the select behavior. */ + if (!(fde->flags & TEVENT_FD_READ)) { + TEVENT_FD_NOT_WRITEABLE(fde); + continue; + } + flags |= TEVENT_FD_READ; + } + if (pfd->revents & POLLIN) { flags |= TEVENT_FD_READ; } if (pfd->revents & POLLOUT) { |