summaryrefslogtreecommitdiffstats
path: root/extensions/Push
diff options
context:
space:
mode:
authorByron Jones <bjones@mozilla.com>2013-01-02 16:20:14 +0100
committerByron Jones <bjones@mozilla.com>2013-01-02 16:20:14 +0100
commitf3975a11266aad202f31ce6fe8e86f321c68cd3e (patch)
tree29f8b3b740dfddfc287649eefb3b2d8b78e57a49 /extensions/Push
parentb10a11cc341499745c0495406bd207db4982b322 (diff)
downloadbugzilla-f3975a11266aad202f31ce6fe8e86f321c68cd3e.tar.gz
bugzilla-f3975a11266aad202f31ce6fe8e86f321c68cd3e.tar.xz
Bug 825828: if the connection to the database is lost, the push daemon terminates
Diffstat (limited to 'extensions/Push')
-rw-r--r--extensions/Push/lib/Config.pm2
-rw-r--r--extensions/Push/lib/Push.pm19
2 files changed, 18 insertions, 3 deletions
diff --git a/extensions/Push/lib/Config.pm b/extensions/Push/lib/Config.pm
index 31fa6af36..7033b4195 100644
--- a/extensions/Push/lib/Config.pm
+++ b/extensions/Push/lib/Config.pm
@@ -80,7 +80,7 @@ sub load {
# done, update self
foreach my $name (keys %$config) {
my $value = $self->option($name)->{type} eq 'password' ? '********' : $config->{$name};
- $logger->debug(sprintf("%s: set %s=%s\n", $self->{_name}, $name, $value));
+ $logger->debug(sprintf("%s: set %s=%s\n", $self->{_name}, $name, $value || ''));
$self->{$name} = $config->{$name};
}
}
diff --git a/extensions/Push/lib/Push.pm b/extensions/Push/lib/Push.pm
index 76b82dda4..aaac0bbd6 100644
--- a/extensions/Push/lib/Push.pm
+++ b/extensions/Push/lib/Push.pm
@@ -49,8 +49,10 @@ sub start {
}
while(1) {
- $self->_reload();
- $self->push();
+ if ($self->_dbh_check()) {
+ $self->_reload();
+ $self->push();
+ }
sleep(POLL_INTERVAL_SECONDS);
}
}
@@ -246,4 +248,17 @@ sub log {
return $self->{log};
}
+sub _dbh_check {
+ my ($self) = @_;
+ eval {
+ Bugzilla->dbh->selectrow_array("SELECT 1 FROM push");
+ };
+ if ($@) {
+ $self->logger->error(clean_error($@));
+ return 0;
+ } else {
+ return 1;
+ }
+}
+
1;