diff --git a/webtools/tinderbox2/src/bin/processmail_builds b/webtools/tinderbox2/src/bin/processmail_builds index 6857f7495e3..cbf295431b9 100755 --- a/webtools/tinderbox2/src/bin/processmail_builds +++ b/webtools/tinderbox2/src/bin/processmail_builds @@ -12,8 +12,8 @@ # server. No locks are used by the mail processes, data is passed to # the tinderbox server in a maildir like format. -# $Revision: 1.11 $ -# $Date: 2002-02-25 19:34:41 $ +# $Revision: 1.12 $ +# $Date: 2002-04-24 03:27:35 $ # $Author: kestes%walrus.com $ # $Source: /home/jrmuizel/cvs-mirror/mozilla/webtools/tinderbox2/src/bin/processmail_builds,v $ # $Name: $ @@ -506,7 +506,7 @@ sub check_required_vars { $err_string .= "Variable: 'timenow' not set.\n"; } else { - if( abs($TINDERBOX{'timenow'} - $TIME) < ($main::SECONDS_PER_HOUR*10) ){ + if( main::is_time_in_sync($TINDERBOX{'timenow'}) ){ $timenow = $TINDERBOX{'timenow'}; } else { $err_string .= ( @@ -529,20 +529,16 @@ sub check_required_vars { if( $TINDERBOX{'starttime'} eq ''){ $err_string .= "Variable: 'tinderbox: starttime' not set.\n"; } else { - if( abs($TINDERBOX{'starttime'} - $TIME) < ($main::SECONDS_PER_HOUR*10) ){ + if( $TINDERBOX{'starttime'} <= $TINDERBOX{'timenow'} ){ $starttime = $TINDERBOX{'starttime'}; } else { $err_string .= ( "Variable: 'tinderbox: starttime:',". - " is not of the form ". - "MM/DD/YY HH:MM:SS, or unix date, ". - "or your clock is set incorrectly, ". - "or the mail was delayed for a long time.\n". - "starttime: $TINDERBOX{'starttime'}, timenow: $TIME, (". - ( ($TINDERBOX{'starttime'}-$TIME) / - $main::SECONDS_PER_MINUTE ). - " minutes)\n". - ""); + " is grater then the tinderbox: timenow.\n". + "starttime: $TINDERBOX{'starttime'}, ". + "timenow: $TINDERBOX{'timenow'}". + "\n". + ""); } } diff --git a/webtools/tinderbox2/src/lib/Utils.pm b/webtools/tinderbox2/src/lib/Utils.pm index 839163d4d98..46774ed058e 100755 --- a/webtools/tinderbox2/src/lib/Utils.pm +++ b/webtools/tinderbox2/src/lib/Utils.pm @@ -3,8 +3,8 @@ # Utils.pm - General purpose utility functions. Every project needs a # kludge bucket for common access. -# $Revision: 1.26 $ -# $Date: 2001-12-14 20:13:01 $ +# $Revision: 1.27 $ +# $Date: 2002-04-24 03:27:31 $ # $Author: kestes%walrus.com $ # $Source: /home/jrmuizel/cvs-mirror/mozilla/webtools/tinderbox2/src/lib/Utils.pm,v $ # $Name: $ @@ -127,6 +127,12 @@ sub set_static_vars { (60 * 15) ); + $SECONDS_AGO_ACCEPTABLE = $TinderConfig::SECONDS_AGO_ACCEPTABLE || + ($SECONDS_PER_HOUR*10); + + $SECONDS_FROM_NOW_ACCEPTABLE = $TinderConfig::SECONDS_FROM_NOW_ACCEPTABLE || + ($SECONDS_PER_MINUTE*10); + @ORIG_ARGV = @ARGV; # set a minimal path. All the commands we run should have explicit @@ -543,6 +549,24 @@ sub is_time_valid { } +# return true iff the argument is a time which is a reasonable time to +# recive data about (it should not be in the future, or too far in the +# past). + +sub is_time_in_sync { + my ($time) = @_; + + $valid = ( + + ( ($TIME - $time) <= ($SECONDS_AGO_ACCEPTABLE) ) && + ( ($TIME + $time) >= ($SECONDS_FROM_NOW_ACCEPTABLE) ) + + ); + + return $valid; +} + + # Convert dates in form "MM/DD/YY HH:MM:SS" to unix date, there # are better modules in CPAN to do this kind of conversion but we # do not wish to create additional dependencies if they are not