lkml.org 
[lkml]   [2014]   [Aug]   [26]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
From
SubjectRe: [PATCH 10/10] tools lib api: Adopt fdarray class from perf's evlist
Date
Hi Arnaldo,

On Fri, 22 Aug 2014 17:59:50 -0300, Arnaldo Carvalho de Melo wrote:
> +int fdarray__add(struct fdarray *fda, int fd)
> +{
> + /*
> + * XXX: 64 is arbitrary, just not to call realloc at each fd.
> + * Find a better autogrowing heuristic
> + */
> + if (fda->nr == fda->nr_alloc &&
> + fdarray__grow(fda, 64) < 0)
> + return -ENOMEM;
> +
> + fcntl(fd, F_SETFL, O_NONBLOCK);
> + fda->entries[fda->nr].fd = fd;
> + fda->entries[fda->nr].events = POLLIN | POLLERR | POLLHUP;
> + fda->nr++;
> + return 0;
> +}

To be more generic api, I think it'd be better receiving events from
user rather than hard-coding. Also it might be useful to let user
sets a grow hint (during init?) as well.

Thanks,
Namhyung


\
 
 \ /
  Last update: 2014-08-26 10:21    [W:0.132 / U:0.120 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site