diff options
author | Stefan Metzmacher <metze@samba.org> | 2013-02-15 11:24:59 +0100 |
---|---|---|
committer | Jeremy Allison <jra@samba.org> | 2013-03-01 11:59:20 -0800 |
commit | f86df3e364f55be5f320463e3c1b89ee3a49115e (patch) | |
tree | 4d99837b8a253a72bdf8cb6004184cf6808917ff /lib | |
parent | 883d20a9bf7444e6338e13d6efbcbc257e1d78b7 (diff) | |
download | samba-f86df3e364f55be5f320463e3c1b89ee3a49115e.tar.gz samba-f86df3e364f55be5f320463e3c1b89ee3a49115e.tar.xz samba-f86df3e364f55be5f320463e3c1b89ee3a49115e.zip |
tevent: remember the errno from select(), poll() and epoll_wait()
Signed-off-by: Stefan Metzmacher <metze@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
Diffstat (limited to 'lib')
-rw-r--r-- | lib/tevent/tevent_epoll.c | 6 | ||||
-rw-r--r-- | lib/tevent/tevent_poll.c | 4 | ||||
-rw-r--r-- | lib/tevent/tevent_select.c | 6 |
3 files changed, 11 insertions, 5 deletions
diff --git a/lib/tevent/tevent_epoll.c b/lib/tevent/tevent_epoll.c index 61a8525d2bc..99d4806db08 100644 --- a/lib/tevent/tevent_epoll.c +++ b/lib/tevent/tevent_epoll.c @@ -313,6 +313,7 @@ static int epoll_event_loop(struct epoll_event_context *epoll_ev, struct timeval #define MAXEVENTS 1 struct epoll_event events[MAXEVENTS]; int timeout = -1; + int wait_errno; if (epoll_ev->epoll_fd == -1) return -1; @@ -328,15 +329,16 @@ static int epoll_event_loop(struct epoll_event_context *epoll_ev, struct timeval tevent_trace_point_callback(epoll_ev->ev, TEVENT_TRACE_BEFORE_WAIT); ret = epoll_wait(epoll_ev->epoll_fd, events, MAXEVENTS, timeout); + wait_errno = errno; tevent_trace_point_callback(epoll_ev->ev, TEVENT_TRACE_AFTER_WAIT); - if (ret == -1 && errno == EINTR && epoll_ev->ev->signal_events) { + if (ret == -1 && wait_errno == EINTR && epoll_ev->ev->signal_events) { if (tevent_common_check_signal(epoll_ev->ev)) { return 0; } } - if (ret == -1 && errno != EINTR) { + if (ret == -1 && wait_errno != EINTR) { epoll_panic(epoll_ev, "epoll_wait() failed", true); return -1; } diff --git a/lib/tevent/tevent_poll.c b/lib/tevent/tevent_poll.c index 89b3bbc0b3a..81a7176f8ee 100644 --- a/lib/tevent/tevent_poll.c +++ b/lib/tevent/tevent_poll.c @@ -444,6 +444,7 @@ static int poll_event_loop_poll(struct tevent_context *ev, int timeout = -1; unsigned first_fd; unsigned i; + int poll_errno; if (ev->signal_events && tevent_common_check_signal(ev)) { return 0; @@ -462,9 +463,10 @@ static int poll_event_loop_poll(struct tevent_context *ev, tevent_trace_point_callback(poll_ev->ev, TEVENT_TRACE_BEFORE_WAIT); pollrtn = poll(poll_ev->fds, poll_ev->num_fds, timeout); + poll_errno = errno; tevent_trace_point_callback(poll_ev->ev, TEVENT_TRACE_AFTER_WAIT); - if (pollrtn == -1 && errno == EINTR && ev->signal_events) { + if (pollrtn == -1 && poll_errno == EINTR && ev->signal_events) { tevent_common_check_signal(ev); return 0; } diff --git a/lib/tevent/tevent_select.c b/lib/tevent/tevent_select.c index 7e0c927dd94..ffb0d18c2e9 100644 --- a/lib/tevent/tevent_select.c +++ b/lib/tevent/tevent_select.c @@ -144,6 +144,7 @@ static int select_event_loop_select(struct select_event_context *select_ev, stru fd_set r_fds, w_fds; struct tevent_fd *fde; int selrtn; + int select_errno; /* we maybe need to recalculate the maxfd */ if (select_ev->maxfd == EVENT_INVALID_MAXFD) { @@ -175,15 +176,16 @@ static int select_event_loop_select(struct select_event_context *select_ev, stru tevent_trace_point_callback(select_ev->ev, TEVENT_TRACE_BEFORE_WAIT); selrtn = select(select_ev->maxfd+1, &r_fds, &w_fds, NULL, tvalp); + select_errno = errno; tevent_trace_point_callback(select_ev->ev, TEVENT_TRACE_AFTER_WAIT); - if (selrtn == -1 && errno == EINTR && + if (selrtn == -1 && select_errno == EINTR && select_ev->ev->signal_events) { tevent_common_check_signal(select_ev->ev); return 0; } - if (selrtn == -1 && errno == EBADF) { + if (selrtn == -1 && select_errno == EBADF) { /* the socket is dead! this should never happen as the socket should have first been made readable and that should have removed |