From fe866d996f54df0c5687c94b98abff5410ef02c9 Mon Sep 17 00:00:00 2001 From: Paul Sokolovsky Date: Sun, 5 Mar 2017 13:51:22 +0100 Subject: [PATCH] unix/moduselect: Properly implement ipoll object iteration. TODO: There's another issue to care about: poll set being modified during iteration. --- unix/moduselect.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/unix/moduselect.c b/unix/moduselect.c index 76938329fc..37a3a33b28 100644 --- a/unix/moduselect.c +++ b/unix/moduselect.c @@ -253,8 +253,9 @@ STATIC mp_obj_t poll_iternext(mp_obj_t self_in) { self->iter_cnt--; - struct pollfd *entries = self->entries; + struct pollfd *entries = self->entries + self->iter_idx; for (int i = self->iter_idx; i < self->len; i++, entries++) { + self->iter_idx++; if (entries->revents != 0) { mp_obj_tuple_t *t = MP_OBJ_TO_PTR(self->ret_tuple); // If there's an object stored, return it, otherwise raw fd