Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
bugzilla
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
etersoft
bugzilla
Commits
2f9f28d0
Commit
2f9f28d0
authored
Aug 17, 2004
by
bugreport%peshkin.net
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Bug 255772: Prevent whine.pl from running endless whining loop
patch by erik r=joel, jouni a=myk
parent
9e691411
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
30 additions
and
9 deletions
+30
-9
whine.pl
whine.pl
+30
-9
No files found.
whine.pl
View file @
2f9f28d0
...
...
@@ -39,6 +39,12 @@ my $template = Bugzilla->template;
my
$dbh
=
Bugzilla
->
dbh
;
my
$sth
;
# @seen_schedules is a list of all of the schedules that have already been
# touched by reset_timer. If reset_timer sees a schedule more than once, it
# sets it to NULL so it won't come up again until the next execution of
# whine.pl
my
@seen_schedules
=
();
# These statement handles should live outside of their functions in order to
# allow the database to keep their SQL compiled.
my
$sth_run_queries
=
...
...
@@ -517,6 +523,15 @@ sub check_today {
sub
reset_timer
{
my
$schedule_id
=
shift
;
# Schedules may not be executed more than once for each invocation of
# whine.pl -- there are legitimate circumstances that can cause this, like
# a set of whines that take a very long time to execute, so it's done
# quietly.
if
(
grep
(
/^$schedule_id$/
,
@seen_schedules
))
{
null_schedule
(
$schedule_id
);
}
push
@seen_schedules
,
$schedule_id
;
$sth
=
$dbh
->
prepare
(
"SELECT run_day, run_time FROM whine_schedules "
.
"WHERE id=?"
);
$sth
->
execute
(
$schedule_id
);
...
...
@@ -571,17 +586,23 @@ sub reset_timer {
$sth
->
execute
(
$minute_offset
,
$schedule_id
);
}
else
{
# The minute offset is zero or less, which is not supposed to happen.
# This is a kind of safeguard against infinite loops. NULL schedules
# will not be available to get_next_event until they are rescheduled.
$sth
=
$dbh
->
prepare
(
"UPDATE whine_schedules "
.
"SET run_next = NULL "
.
"WHERE id=?"
);
$sth
->
execute
(
$schedule_id
);
# complain to STDERR
print
STDERR
"Bad minute_offset for schedule ID $schedule_id\n"
;
# complain to STDERR
null_schedule
(
$schedule_id
);
print
STDERR
"Error: bad minute_offset for schedule ID $schedule_id\n"
;
}
}
# null_schedule is used to safeguard against infinite loops. Schedules with
# run_next set to NULL will not be available to get_next_event until they are
# rescheduled, which only happens when whine.pl starts.
sub
null_schedule
{
my
$schedule_id
=
shift
;
$sth
=
$dbh
->
prepare
(
"UPDATE whine_schedules "
.
"SET run_next = NULL "
.
"WHERE id=?"
);
$sth
->
execute
(
$schedule_id
);
}
# get_next_date determines the difference in days between now and the next
# time a schedule should run, excluding today
#
...
...
@@ -628,7 +649,7 @@ sub get_next_date {
}
$add_days
=
$day_num
-
$now_weekday
;
if
(
$add_days
<
0
)
{
# it's next week
if
(
$add_days
<
=
0
)
{
# it's next week
$add_days
+=
7
;
}
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment