summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMark Kettenis <kettenis@openbsd.org>2013-12-15 14:31:10 +0100
committerMatthieu Herrb <matthieu.herrb@laas.fr>2013-12-16 08:22:06 +0100
commitbda9fe96d1ffbf5f1fe4c3a7f04600fc9d71809b (patch)
tree78229fa77f55208d6f16995fdfd10b0eeeb12f98
parentf4bfb14f53a939574da1f5995f0dad949898b86a (diff)
sync: Avoid ridiculously long timeoutsfor-keith
On OpenBSD, passing a timeout longer than 100000000 seconds to select(2) will make it fail with EINVAL. As this is original 4.4BSD behaviour it is not inconceivable that other systems suffer from the same problem. And Linux, though not suffering from any 4.4BSD heritage, briefly did something similar: <https://lkml.org/lkml/2012/8/31/263> So avoid calling AdjustWaitForDelay() instead of setting the timeout to (effectively) ULONG_MAX milliseconds. Signed-off-by: Mark Kettenis <kettenis@openbsd.org>
-rw-r--r--Xext/sync.c7
1 files changed, 2 insertions, 5 deletions
diff --git a/Xext/sync.c b/Xext/sync.c
index 2d58ea1fa..c33b5b5bb 100644
--- a/Xext/sync.c
+++ b/Xext/sync.c
@@ -2731,27 +2731,24 @@ IdleTimeBlockHandler(pointer pCounter, struct timeval **wt, pointer LastSelectMa
* If we've been idle more than it, and someone wants to know about
* that level-triggered, schedule an immediate wakeup.
*/
- unsigned long timeout = -1;
if (XSyncValueLessThan(idle, *greater)) {
XSyncValue value;
Bool overflow;
XSyncValueSubtract(&value, *greater, idle, &overflow);
- timeout = min(timeout, XSyncValueLow32(value));
+ AdjustWaitForDelay(wt, XSyncValueLow32(value));
}
else {
for (list = counter->sync.pTriglist; list;
list = list->next) {
trig = list->pTrigger;
if (trig->CheckTrigger(trig, old_idle)) {
- timeout = min(timeout, 0);
+ AdjustWaitForDelay(wt, 0);
break;
}
}
}
-
- AdjustWaitForDelay(wt, timeout);
}
counter->value = old_idle; /* pop */