lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite for Android: free password hash cracker in your pocket
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20140911103319.GA13634@krava.brq.redhat.com>
Date:	Thu, 11 Sep 2014 12:33:19 +0200
From:	Jiri Olsa <jolsa@...hat.com>
To:	Arnaldo Carvalho de Melo <acme@...nel.org>
Cc:	linux-kernel@...r.kernel.org,
	Arnaldo Carvalho de Melo <acme@...hat.com>,
	Adrian Hunter <adrian.hunter@...el.com>,
	Borislav Petkov <bp@...e.de>,
	Corey Ashford <cjashfor@...ux.vnet.ibm.com>,
	David Ahern <dsahern@...il.com>,
	Frederic Weisbecker <fweisbec@...il.com>,
	Ingo Molnar <mingo@...nel.org>,
	Jean Pihet <jean.pihet@...aro.org>,
	Jiri Olsa <jolsa@...nel.org>,
	Namhyung Kim <namhyung@...nel.org>,
	Paul Mackerras <paulus@...ba.org>,
	Peter Zijlstra <a.p.zijlstra@...llo.nl>
Subject: Re: [PATCH 13/14] tools lib fd array: Allow associating an integer
 cookie with each entry

On Wed, Sep 10, 2014 at 11:08:48AM -0300, Arnaldo Carvalho de Melo wrote:

SNIP

>  }
>  
> -int fdarray__filter(struct fdarray *fda, short revents)
> +int fdarray__filter(struct fdarray *fda, short revents,
> +		    void (*entry_destructor)(struct fdarray *fda, int fd))
>  {
>  	int fd, nr = 0;
>  
> @@ -80,11 +94,17 @@ int fdarray__filter(struct fdarray *fda, short revents)
>  		return 0;
>  
>  	for (fd = 0; fd < fda->nr; ++fd) {
> -		if (fda->entries[fd].revents & revents)
> +		if (fda->entries[fd].revents & revents) {
> +			if (entry_destructor)
> +				entry_destructor(fda, fd);

the desctructor callback could have the 'priv' as an argument
so we dont need to touch fdarray internals in upper layer

> +
>  			continue;
> +		}
>  
> -		if (fd != nr)
> +		if (fd != nr) {
>  			fda->entries[nr] = fda->entries[fd];
> +			fda->priv[nr]	 = fda->priv[fd];
> +		}
>  
>  		++nr;
>  	}
> diff --git a/tools/lib/api/fd/array.h b/tools/lib/api/fd/array.h
> index de38361ba69e..7b2870a96898 100644
> --- a/tools/lib/api/fd/array.h
> +++ b/tools/lib/api/fd/array.h
> @@ -10,6 +10,7 @@ struct fdarray {
>  	int	       nr_alloc;
>  	int	       nr_autogrow;
>  	struct pollfd *entries;
> +	int	      *priv;

I like the idea of private pointer for each fd, but I think
it should be 'void*' to keep the library generic. The 'int*'
is related only to the evlist usage of this.

jirka
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ