[memcached] bradfitz, r385: potential race

commits at code.sixapart.com commits at code.sixapart.com
Sat Sep 9 19:49:37 UTC 2006


potential race

U   trunk/server/t/expirations.t


Modified: trunk/server/t/expirations.t
===================================================================
--- trunk/server/t/expirations.t	2006-09-09 19:49:09 UTC (rev 384)
+++ trunk/server/t/expirations.t	2006-09-09 19:49:36 UTC (rev 385)
@@ -10,6 +10,20 @@
 my $sock = $server->sock;
 my $expire;
 
+sub wait_for_early_second {
+    use Time::HiRes ();
+    my $tsh = Time::HiRes::time();
+    my $ts = int($tsh);  # in case time was overloaded to be hires.
+    return if ($tsh - $ts) < 0.5;
+    while (1) {
+        my $t = int(time());
+        return if $t != $ts;
+        select undef, undef, undef, 0.10;  # 1/10th of a second sleeps until time changes.
+    }
+}
+
+wait_for_early_second();
+
 print $sock "set foo 0 1 6\r\nfooval\r\n";
 is(scalar <$sock>, "STORED\r\n", "stored foo");
 




More information about the memcached-commits mailing list