+ if (active_fd_count == events->wait.nb_fd) {
+ goto end;
+ }
+ while (idle_pfd_index < active_fd_count &&
+ events->wait.events[idle_pfd_index].revents != 0) {
+ idle_pfd_index++;
+ }
+
+ for (i = idle_pfd_index + 1; idle_pfd_index < active_fd_count;
+ i++) {
+ struct pollfd swap_pfd;
+ struct pollfd *idle_pfd = &events->wait.events[idle_pfd_index];
+ struct pollfd *current_pfd = &events->wait.events[i];
+
+ if (idle_pfd->revents != 0) {
+ swap_pfd = *current_pfd;
+ *current_pfd = *idle_pfd;
+ *idle_pfd = swap_pfd;
+ idle_pfd_index++;
+ }
+ }
+
+end:
+ return ret;