Re: [PATCH] fs: sys_poll with timeout -1 bug fix

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

 



On Thu, 2006-06-15 at 17:33 +0200, frode isaksen wrote:
> From: Frode Isaksen <[email protected]>
> 
> If you do a poll() call with timeout -1, the wait will be a big  
> number (depending on HZ)  instead of infinite wait, since -1 is  
> passed to the msecs_to_jiffies function.
> 
> Signed-off-by: Frode Isaksen <[email protected]>
> 
> ---
> --- linux-2.6.16.20/fs/select.c.orig.c	2006-06-05 19:18:23.000000000  
> +0200
> +++ linux-2.6.16.20/fs/select.c	2006-06-15 14:20:47.000000000 +0200
> @@ -699,9 +699,9 @@ out_fds:
>   asmlinkage long sys_poll(struct pollfd __user *ufds, unsigned int  
> nfds,
>   			long timeout_msecs)
>   {
> -	s64 timeout_jiffies = 0;
> +	s64 timeout_jiffies;
> 
> -	if (timeout_msecs) {
> +	if (timeout_msecs > 0) {
>   #if HZ > 1000
>   		/* We can only overflow if HZ > 1000 */
>   		if (timeout_msecs / 1000 > (s64)0x7fffffffffffffffULL / (s64)HZ)
> @@ -709,6 +709,9 @@ asmlinkage long sys_poll(struct pollfd _
>   		else
>   #endif
>   			timeout_jiffies = msecs_to_jiffies(timeout_msecs);
> +	} else {
> +		/* Infinite (-1) or no (0) timeout */
> +		timeout_jiffies = timeout_msecs;

nit: The comment isn't quite right according to the poll manpage. Any
negative number represents an infinite timeout. I think you want:

+ 		/* Infinite (< 0) or no (0) timeout */

>   	}
> 
>   	return do_sys_poll(ufds, nfds, &timeout_jiffies);


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

[Index of Archives]     [Kernel Newbies]     [Netfilter]     [Bugtraq]     [Photo]     [Stuff]     [Gimp]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Video 4 Linux]     [Linux for the blind]     [Linux Resources]
  Powered by Linux