MIME-Version: | 1.0 |
X-Spam-Status: | No, hits=-1.1 required=8.0 tests=BAYES_05,DK_POLICY_SIGNSOME |
Received-SPF: | pass (x1.develooper.com: local policy) |
content-type: | text/plain; charset="utf-8" |
Received: | from la.mx.develooper.com (x1.develooper.com [63.251.223.170]) by diesel.bestpractical.com (Postfix) with SMTP id C3A6B4D80D4 for <bug-business-hours@rt.cpan.org>; Fri, 2 Mar 2007 06:13:05 -0500 (EST) |
Received: | (qmail 20394 invoked by alias); 2 Mar 2007 11:06:17 -0000 |
Received: | from anubis.medic.chalmers.se (HELO anubis.medic.chalmers.se) (129.16.30.218) by la.mx.develooper.com (qpsmtpd/0.28) with ESMTP; Fri, 02 Mar 2007 03:06:14 -0800 |
Received: | from [129.16.223.108] (monk.ita.chalmers.se [129.16.223.108]) (Authenticated sender: fors) by mail.chalmers.se (Postfix) with ESMTP id 38498461E for <bug-business-hours@rt.cpan.org>; Fri, 2 Mar 2007 12:06:07 +0100 (CET) |
Delivered-To: | cpan-bug+business-hours@diesel.bestpractical.com |
User-Agent: | Thunderbird 1.5.0.9 (X11/20061215) |
Subject: | Infinite loop condition in first_after |
Return-Path: | <fors@chalmers.se> |
X-Original-To: | bug-business-hours@rt.cpan.org |
X-Spam-Check-BY: | la.mx.develooper.com |
Date: | Fri, 02 Mar 2007 12:06:07 +0100 |
Message-Id: | <45E8051F.7050203@chalmers.se> |
To: | bug-business-hours@rt.cpan.org |
X-Enigmail-Version: | 0.94.1.1 |
Content-Transfer-Encoding: | 7bit |
From: | Patrick Forsberg <fors@chalmers.se> |
X-RT-Original-Encoding: | ISO-8859-1 |
Content-Length: | 1054 |
Hi there.
There's a logical error in the first_after function of Business::Hours
$MAXTIME is set to a fix number
$period is set to a fix number less than $MAXTIME
the while ($hours->empty) loop has function to exit if ($end >= $start + $MAXTIME)
but at the end of the loop $start=$end and $end = $start+period so the exit condition will never be true;
Something like this will solve the problem
###########
--- Hours.pm 2005-07-08 17:44:00.000000000 +0200
+++ Hours.pm 2007-03-02 12:03:16.000000000 +0100
@@ -336,13 +336,14 @@
# the maximum time after which we stop searching for business hours
my $MAXTIME = (30 * 24 * 60 * 60); # 30 days
+ my $ENDTIME = $start + $MAXTIME;
my $period = (24 * 60 * 60);
my $end = $start + $period;
my $hours = new Set::IntSpan;
while ($hours->empty) {
- if ($end >= $start + $MAXTIME) {
+ if ($end >= $ENDTIME) {
return -1;
}
$hours = $self->for_timespan(Start => $start, End => $end);
###########
Regards,
Patrick Forsberg