public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] fs: sys_poll with timeout -1 bug fix
@ 2006-06-15 15:33 frode isaksen
  2006-06-15 15:56 ` Nishanth Aravamudan
  2006-06-15 21:13 ` Matt Helsley
  0 siblings, 2 replies; 4+ messages in thread
From: frode isaksen @ 2006-06-15 15:33 UTC (permalink / raw)
  To: akpm, Nishanth Aravamudan; +Cc: linux-kernel

From: Frode Isaksen <frode.isaksen@gmail.com>

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 <frode.isaksen@gmail.com>

---
--- 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;
  	}

  	return do_sys_poll(ufds, nfds, &timeout_jiffies);


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] fs: sys_poll with timeout -1 bug fix
  2006-06-15 15:33 [PATCH] fs: sys_poll with timeout -1 bug fix frode isaksen
@ 2006-06-15 15:56 ` Nishanth Aravamudan
  2006-06-15 21:13 ` Matt Helsley
  1 sibling, 0 replies; 4+ messages in thread
From: Nishanth Aravamudan @ 2006-06-15 15:56 UTC (permalink / raw)
  To: frode isaksen; +Cc: akpm, linux-kernel

On 15.06.2006 [17:33:05 +0200], frode isaksen wrote:
> From: Frode Isaksen <frode.isaksen@gmail.com>
> 
> 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 <frode.isaksen@gmail.com>
Acked-by: Nishanth Aravamudan <nacc@us.ibm.com>

Thanks,
Nish

-- 
Nishanth Aravamudan <nacc@us.ibm.com>
IBM Linux Technology Center

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] fs: sys_poll with timeout -1 bug fix
  2006-06-15 15:33 [PATCH] fs: sys_poll with timeout -1 bug fix frode isaksen
  2006-06-15 15:56 ` Nishanth Aravamudan
@ 2006-06-15 21:13 ` Matt Helsley
  2006-06-15 21:26   ` Nishanth Aravamudan
  1 sibling, 1 reply; 4+ messages in thread
From: Matt Helsley @ 2006-06-15 21:13 UTC (permalink / raw)
  To: frode isaksen; +Cc: Andrew Morton, Nishanth Aravamudan, LKML

On Thu, 2006-06-15 at 17:33 +0200, frode isaksen wrote:
> From: Frode Isaksen <frode.isaksen@gmail.com>
> 
> 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 <frode.isaksen@gmail.com>
> 
> ---
> --- 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);



^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] fs: sys_poll with timeout -1 bug fix
  2006-06-15 21:13 ` Matt Helsley
@ 2006-06-15 21:26   ` Nishanth Aravamudan
  0 siblings, 0 replies; 4+ messages in thread
From: Nishanth Aravamudan @ 2006-06-15 21:26 UTC (permalink / raw)
  To: Matt Helsley; +Cc: frode isaksen, Andrew Morton, LKML

On 15.06.2006 [14:13:29 -0700], Matt Helsley wrote:
> On Thu, 2006-06-15 at 17:33 +0200, frode isaksen wrote:
> > From: Frode Isaksen <frode.isaksen@gmail.com>
> > 
> > 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 <frode.isaksen@gmail.com>
> > 
> > ---
> > --- 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 */

Err, true.

Thanks,
Nish

-- 
Nishanth Aravamudan <nacc@us.ibm.com>
IBM Linux Technology Center

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2006-06-15 21:27 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2006-06-15 15:33 [PATCH] fs: sys_poll with timeout -1 bug fix frode isaksen
2006-06-15 15:56 ` Nishanth Aravamudan
2006-06-15 21:13 ` Matt Helsley
2006-06-15 21:26   ` Nishanth Aravamudan

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox