[Spread-cvs] commit: r417 - branches/events_testing/daemon

jschultz at spread.org jschultz at spread.org
Sun May 17 18:52:48 EDT 2009


Author: jschultz
Date: 2009-05-17 18:52:48 -0400 (Sun, 17 May 2009)
New Revision: 417

Modified:
   branches/events_testing/daemon/events.c
Log:
Changed epoll backend's translation of timeout to round more appropriately.



Modified: branches/events_testing/daemon/events.c
===================================================================
--- branches/events_testing/daemon/events.c	2009-05-17 22:34:06 UTC (rev 416)
+++ branches/events_testing/daemon/events.c	2009-05-17 22:52:48 UTC (rev 417)
@@ -2264,18 +2264,23 @@
 
   if (delta_timeout != NULL) {
 
-    tmp_timeout = delta_timeout->sec * 1000.0 + delta_timeout->usec / 1000.0;
-    assert(tmp_timeout >= 0.0);
+    if (delta_timeout->sec == 0 && delta_timeout->usec == 0) {
+      timeout = 0;
 
-    if (tmp_timeout <= INT_MAX) {
-      timeout = (int) tmp_timeout;                            /* TODO: should we round down like this? */
-
     } else {
-      timeout = INT_MAX;
+      tmp_timeout = delta_timeout->sec * 1000.0 + (999 + delta_timeout->usec) / 1000.0;  /* [1, 1000] usec -> round up to 1 ms */
+      assert(tmp_timeout >= 0.0);
+      
+      if (tmp_timeout <= INT_MAX) {
+        timeout = (int) tmp_timeout;                          /* round off excess usec */
+        
+      } else {
+        timeout = INT_MAX;
+      }
     }
 
   } else if (lvl_info->num_poll_fds != 0) {
-    timeout = -1;
+      timeout = -1;                                           /* infinite timeout */
 
   } else {
     ret = E_DEADEND;                                          /* error on infinite timeout and no fds to watch */




More information about the Spread-cvs mailing list