Re: [PATCH] Remove & ban use of select() for waiting for I/O

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On 05/13/2013 07:45 AM, Daniel P. Berrange wrote:
> From: "Daniel P. Berrange" <berrange@xxxxxxxxxx>
> 
> Use of the select() system call is inherantly dangerous since
> applications will hit a buffer overrun if any FD number exceeds
> the size of the select set size (typically 1024). Replace the
> two uses of select() with poll() and use cfg.mk to ban any
> future use of select().
> 
> NB: This changes the phyp driver so that it uses an infinite
> timeout, instead of busy-waiting for 1ms at a time.
> 
> Signed-off-by: Daniel P. Berrange <berrange@xxxxxxxxxx>
> ---

> +++ b/cfg.mk
> @@ -444,6 +444,14 @@ sc_prohibit_nonreentrant:
>  	done ; \
>  	exit $$fail
>  
> +sc_prohibit_select:
> +	@fail=0 ;							\
> +	(prohibit="\\<select *\\("					\
> +	 halt="use poll(), not select()"				\
> +	 $(_sc_search_regexp)						\
> +	) || fail=1;							\
> +	exit $$fail

Overkill.  $(_sc_search_regexp) exits with non-zero status, so it is
sufficient to write:

+sc_prohibit_select:
+	@prohibit="\\<select *\\("				\
+	halt="use poll(), not select()"				\
+	 $(_sc_search_regexp)

> +++ b/src/util/virnetlink.c
> @@ -48,7 +48,7 @@
>  
>  #define VIR_FROM_THIS VIR_FROM_NET
>  
> -#define NETLINK_ACK_TIMEOUT_S  2
> +#define NETLINK_ACK_TIMEOUT_S  2*1000

Needs parenthesis.

ACK with those fixes.

-- 
Eric Blake   eblake redhat com    +1-919-301-3266
Libvirt virtualization library http://libvirt.org

Attachment: signature.asc
Description: OpenPGP digital signature

--
libvir-list mailing list
libvir-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/libvir-list

[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]