+ if (active_fd_count == events->wait.nb_fd) {
+ goto end;
+ }
+
+ while (consecutive_entries != active_fd_count) {
+ struct pollfd *current = &events->wait.events[pos];
+ struct pollfd idle_entry;
+
+ if (current->revents != 0) {
+ consecutive_entries++;
+ pos++;
+ continue;
+ }
+
+ non_idle_pos = pos;
+
+ /* Look for next non-idle entry. */
+ while (events->wait.events[++non_idle_pos].revents == 0);
+
+ /* Swap idle and non-idle entries. */
+ idle_entry = *current;
+ *current = events->wait.events[non_idle_pos];
+ events->wait.events[non_idle_pos] = idle_entry;
+
+ consecutive_entries++;
+ pos++;
+ }
+end:
+ return ret;