summaryrefslogtreecommitdiffstats
path: root/Bugzilla/Job/Mailer.pm
diff options
context:
space:
mode:
Diffstat (limited to 'Bugzilla/Job/Mailer.pm')
-rw-r--r--Bugzilla/Job/Mailer.pm40
1 files changed, 21 insertions, 19 deletions
diff --git a/Bugzilla/Job/Mailer.pm b/Bugzilla/Job/Mailer.pm
index a376a9256..d73e4f009 100644
--- a/Bugzilla/Job/Mailer.pm
+++ b/Bugzilla/Job/Mailer.pm
@@ -17,40 +17,42 @@ BEGIN { eval "use base qw(TheSchwartz::Worker)"; }
# The longest we expect a job to possibly take, in seconds.
use constant grab_for => 300;
+
# We don't want email to fail permanently very easily. Retry for 30 days.
use constant max_retries => 725;
# The first few retries happen quickly, but after that we wait an hour for
# each retry.
sub retry_delay {
- my ($class, $num_retries) = @_;
- if ($num_retries < 5) {
- return (10, 30, 60, 300, 600)[$num_retries];
- }
- # One hour
- return 60*60;
+ my ($class, $num_retries) = @_;
+ if ($num_retries < 5) {
+ return (10, 30, 60, 300, 600)[$num_retries];
+ }
+
+ # One hour
+ return 60 * 60;
}
sub work {
- my ($class, $job) = @_;
- eval { $class->process_job($job->arg) };
- if (my $error = $@) {
- if ($error eq EMAIL_LIMIT_EXCEPTION) {
- $job->declined();
- }
- else {
- $job->failed($error);
- }
- undef $@;
+ my ($class, $job) = @_;
+ eval { $class->process_job($job->arg) };
+ if (my $error = $@) {
+ if ($error eq EMAIL_LIMIT_EXCEPTION) {
+ $job->declined();
}
else {
- $job->completed;
+ $job->failed($error);
}
+ undef $@;
+ }
+ else {
+ $job->completed;
+ }
}
sub process_job {
- my ($class, $arg) = @_;
- MessageToMTA($arg->{msg}, 1);
+ my ($class, $arg) = @_;
+ MessageToMTA($arg->{msg}, 1);
}
1;