libperf: Avoid internal moving of fdarray fds
Avoid moving of fds by fdarray__filter() so fds indices returned by fdarray__add() can be used for access and processing of objects at struct pollfd *entries. Signed-off-by: Alexey Budankov <alexey.budankov@linux.intel.com> Acked-by: Jiri Olsa <jolsa@redhat.com> Acked-by: Namhyung Kim <namhyung@kernel.org> Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com> Cc: Andi Kleen <ak@linux.intel.com> Cc: Peter Zijlstra <peterz@infradead.org> Link: http://lore.kernel.org/lkml/676844f8-55d3-c628-23db-aa163a81519e@linux.intel.com Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
This commit is contained in:
committed by
Arnaldo Carvalho de Melo
parent
070b3b5ad7
commit
59b4412f27
@ -93,22 +93,21 @@ int fdarray__filter(struct fdarray *fda, short revents,
|
||||
return 0;
|
||||
|
||||
for (fd = 0; fd < fda->nr; ++fd) {
|
||||
if (!fda->entries[fd].events)
|
||||
continue;
|
||||
|
||||
if (fda->entries[fd].revents & revents) {
|
||||
if (entry_destructor)
|
||||
entry_destructor(fda, fd, arg);
|
||||
|
||||
fda->entries[fd].revents = fda->entries[fd].events = 0;
|
||||
continue;
|
||||
}
|
||||
|
||||
if (fd != nr) {
|
||||
fda->entries[nr] = fda->entries[fd];
|
||||
fda->priv[nr] = fda->priv[fd];
|
||||
}
|
||||
|
||||
++nr;
|
||||
}
|
||||
|
||||
return fda->nr = nr;
|
||||
return nr;
|
||||
}
|
||||
|
||||
int fdarray__poll(struct fdarray *fda, int timeout)
|
||||
|
Reference in New Issue
Block a user