lkml.org 
[lkml]   [2004]   [Feb]   [20]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
Date
From
Subject[PATCH][1/4] poll()/select() timeout behavior
This patch extends the useful range of the poll() timeout parameter
from a mere 2147s (LONG_MAX/(1000*HZ)) to 2147483s (LONG_MAX/1000).

Please apply.

Bill Rugolsky

--- linux/fs/select.c 2004-02-03 22:43:06.000000000 -0500
+++ linux/fs/select.c 2004-02-19 14:29:03.827275000 -0500
@@ -469,11 +469,17 @@
return -EINVAL;

if (timeout) {
- /* Careful about overflow in the intermediate values */
- if ((unsigned long) timeout < MAX_SCHEDULE_TIMEOUT / HZ)
- timeout = (unsigned long)(timeout*HZ+999)/1000+1;
- else /* Negative or overflow */
+ if (timeout < 0) {
timeout = MAX_SCHEDULE_TIMEOUT;
+ } else {
+ /* Careful about overflow in the intermediate values */
+ long seconds = timeout/1000;
+ timeout = ((timeout - 1000*seconds)*HZ + 999)/1000 + 1;
+ if (seconds <= (MAX_SCHEDULE_TIMEOUT-2) / HZ - 1)
+ timeout += seconds*HZ;
+ else
+ timeout = MAX_SCHEDULE_TIMEOUT;
+ }
}

poll_initwait(&table);
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
\
 
 \ /
  Last update: 2005-03-22 14:01    [W:0.035 / U:0.244 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site