chiark / gitweb /
Ensure that timers set to go off in the past don't case a problem.
authormdw <mdw>
Sat, 3 Feb 2001 19:07:08 +0000 (19:07 +0000)
committermdw <mdw>
Sat, 3 Feb 2001 19:07:08 +0000 (19:07 +0000)
sel.c

diff --git a/sel.c b/sel.c
index 04d9ed5464cbe959048b4480f4a844bd09e008ab..62a61cfc9f5eafdb8858c88ff7eab50c6690f0ad 100644 (file)
--- a/sel.c
+++ b/sel.c
@@ -1,6 +1,6 @@
 /* -*-c-*-
  *
- * $Id: sel.c,v 1.8 2000/03/23 20:42:08 mdw Exp $
+ * $Id: sel.c,v 1.9 2001/02/03 19:07:08 mdw Exp $
  *
  * I/O multiplexing support
  *
@@ -30,6 +30,9 @@
 /*----- Revision history --------------------------------------------------* 
  *
  * $Log: sel.c,v $
+ * Revision 1.9  2001/02/03 19:07:08  mdw
+ * Ensure that timers set to go off in the past don't case a problem.
+ *
  * Revision 1.8  2000/03/23 20:42:08  mdw
  * Rearrange timeout handling to avoid list corruptions.
  *
@@ -334,7 +337,12 @@ int sel_select(sel_state *s)
   if (!s->timers)
     a.tvp = 0;
   else {
-    TV_SUB(&a.tv, &s->timers->tv, &a.now);
+    if (TV_CMP(&s->timers->tv, >, &a.now))
+      TV_SUB(&a.tv, &s->timers->tv, &a.now);
+    else {
+      a.tv.tv_sec = 0;
+      a.tv.tv_usec = 0;
+    }
     a.tvp = &a.tv;
   }
   s->args = &a;