timeval: Refresh current time after every wakeup, not just false wakeups.
authorBen Pfaff <blp@nicira.com>
Tue, 2 Jun 2009 21:30:12 +0000 (14:30 -0700)
committerBen Pfaff <blp@nicira.com>
Tue, 2 Jun 2009 21:30:12 +0000 (14:30 -0700)
This failure to update the current time in some cases may have contributed
to false complaints about long poll delays, since this could leave up to
100 ms of time blocked in the poll system call accounted to the next
inter-poll interval instead of to the poll system call itself.

This commit makes vswitch's claimed average poll interval to drop by a
large amount, from ~20 ms to ~2 ms.

lib/timeval.c

index 84384f7162b409998cc0f7db82020eab8e5c5af5..da72d9482066a3638b98ff61bcbb88e67e4a0ac4 100644 (file)
@@ -183,6 +183,7 @@ time_poll(struct pollfd *pollfds, int n_pollfds, int timeout)
         if (retval < 0) {
             retval = -errno;
         }
+        time_refresh();
         if (retval != -EINTR) {
             break;
         }
@@ -191,7 +192,6 @@ time_poll(struct pollfd *pollfds, int n_pollfds, int timeout)
             block_sigalrm(&oldsigs);
             blocked = true;
         }
-        time_refresh();
     }
     if (blocked) {
         unblock_sigalrm(&oldsigs);