summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorVolker Lendecke <vl@samba.org>2011-07-28 14:09:13 +0200
committerVolker Lendecke <vlendec@samba.org>2011-07-28 17:42:23 +0200
commit83740555ea8664da0830f88a1dd5afa69880bb40 (patch)
tree933466cc2f70ea8081f1b05b6c5557ee7a41f57a
parent4dd0a3b5e29e3a39e90a425a827d6a17b9868ced (diff)
downloadsamba-83740555ea8664da0830f88a1dd5afa69880bb40.tar.gz
samba-83740555ea8664da0830f88a1dd5afa69880bb40.tar.bz2
samba-83740555ea8664da0830f88a1dd5afa69880bb40.zip
tevent: Slightly simplify poll_event_loop_poll
No real code change. Do an early return instead of an if-statement, avoiding one level of indentation.
-rw-r--r--lib/tevent/tevent_poll.c71
1 files changed, 38 insertions, 33 deletions
diff --git a/lib/tevent/tevent_poll.c b/lib/tevent/tevent_poll.c
index 0b782e99bb..0a9c0f0b5c 100644
--- a/lib/tevent/tevent_poll.c
+++ b/lib/tevent/tevent_poll.c
@@ -222,40 +222,45 @@ static int poll_event_loop_poll(struct tevent_context *ev,
return 0;
}
- if (pollrtn > 0) {
- /* at least one file descriptor is ready - check
- which ones and call the handler, being careful to allow
- the handler to remove itself when called */
- for (fde = ev->fd_events; fde; fde = fde->next) {
- struct pollfd *pfd;
- uint64_t pfd_idx = fde->additional_flags;
- uint16_t flags = 0;
-
- pfd = &poll_ev->fds[pfd_idx];
-
- 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) {
- flags |= TEVENT_FD_WRITE;
- }
- if (flags != 0) {
- fde->handler(ev, fde, flags,
- fde->private_data);
- break;
+ if (pollrtn <= 0) {
+ /*
+ * No fd's ready
+ */
+ return 0;
+ }
+
+ /* at least one file descriptor is ready - check
+ which ones and call the handler, being careful to allow
+ the handler to remove itself when called */
+
+ for (fde = ev->fd_events; fde; fde = fde->next) {
+ struct pollfd *pfd;
+ uint64_t pfd_idx = fde->additional_flags;
+ uint16_t flags = 0;
+
+ pfd = &poll_ev->fds[pfd_idx];
+
+ 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) {
+ flags |= TEVENT_FD_WRITE;
+ }
+ if (flags != 0) {
+ fde->handler(ev, fde, flags, fde->private_data);
+ break;
}
}