On Mon, May 25, 2020 at 05:17:31PM +0300, Alexey Budankov wrote: SBIP
> +int fdarray__add_stat(struct fdarray *fda, int fd, short revents) > +{ > + int pos = fda->nr_stat; > + > + if (pos >= FDARRAY__STAT_ENTRIES_MAX) > + return -1; > + > + fda->stat_entries[pos].fd = fd; > + fda->stat_entries[pos].events = revents; > + fda->nr_stat++; > + > + return pos; > +} > + > int fdarray__filter(struct fdarray *fda, short revents, > void (*entry_destructor)(struct fdarray *fda, int fd, void > *arg), > void *arg) > @@ -113,7 +133,27 @@ int fdarray__filter(struct fdarray *fda, short revents, > > int fdarray__poll(struct fdarray *fda, int timeout) > { > - return poll(fda->entries, fda->nr, timeout); > + int nr, i, pos, res; > + > + nr = fda->nr; > + > + for (i = 0; i < fda->nr_stat; i++) { > + if (fda->stat_entries[i].fd != -1) { > + pos = fdarray__add(fda, fda->stat_entries[i].fd, > + fda->stat_entries[i].events); > + if (pos >= 0) > + fda->priv[pos].idx = i; > + } > + } hum, so every time we call evlist__poll we end up in here adding more stuff to entries? jirka > + > + res = poll(fda->entries, fda->nr, timeout); > + > + for (i = nr; i < fda->nr; i++) > + fda->stat_entries[fda->priv[i].idx] = fda->entries[i]; > + > + fda->nr = nr; > + > + return res; > } SNIP