svn commit: r581940 - /spamassassin/trunk/masses/mass-check Author: dos
Date: Thu Oct  4 07:58:37 2007
New Revision: 581940

URL: http://svn.apache.org/viewvc?rev=581940&view=rev
Log:
ensure that timestamps are duplicated; duplicate timestamps wipe out the ability to timeout any messages previously sent in the same second, thus preventing mass-check --server from ever completing (it'll wait forever for those messages); this is trivial to trigger by hand and more common to occur naturally the more machines you add to your cluster

Modified:
    spamassassin/trunk/masses/mass-check

Modified: spamassassin/trunk/masses/mass-check
URL: http://svn.apache.org/viewvc/spamassassin/trunk/masses/mass-check?rev=581940&r1=581939&r2=581940&view=diff
==============================================================================
--- spamassassin/trunk/masses/mass-check (original)
+++ spamassassin/trunk/masses/mass-check Thu Oct  4 07:58:37 2007
@@ -162,6 +162,7 @@
 use constant HAS_IO_ZLIB => eval { require IO::Zlib; };
 use constant HAS_IO_SOCKET_SSL => eval { require IO::Socket::SSL; };
 use Config; 
+use constant HAS_TIME_HI_RES => eval { require Time::HiRes; };
 
 
 # default settings
@@ -1221,6 +1222,21 @@
 
   # update timestamp entries
   my $ts = time;
+
+  # make sure the timestamp is unique!  without Time::HiRes it is trivial and
+  # common to have two reissueings of timedout messages in the same second
+  # with Time::HiRes we'll check anyway since we'll waste less time checking
+  # for uniqueness than one of us will waste debugging a report of mass-check
+  # not completing due to someone's wacky clock (some (non-para-)virtualized
+  # servers will have their clocks go forward and backward
+  while (exists $timestamps->{$ts}) {
+    if (HAS_TIME_HI_RES) {
+      $ts = time;
+    } else {
+      $ts += 0.01;
+    }
+  }
+
   foreach (@sent) {
     $msgsout->{$_}->{'timestamp'} = $ts;
   }


