aboutsummaryrefslogtreecommitdiff
path: root/lib/MasterServer/Database/Pg/dbMaintenance.pm
diff options
context:
space:
mode:
authorDarkelarious <darkelarious@333networks.com>2017-08-22 11:00:13 +0200
committerDarkelarious <darkelarious@333networks.com>2017-08-22 11:00:13 +0200
commitc06322da38b4cb76b2036af1a5448083adb8ff20 (patch)
tree189c9f0fec3325be927f763aba23cf18aa68cfe4 /lib/MasterServer/Database/Pg/dbMaintenance.pm
parente0d727670cbeda0db0812c5c9efc503d75f8d0a4 (diff)
downloadMasterServer-Perl-2.4.0.tar.gz
MasterServer-Perl-2.4.0.zip
new server checking mechanism, complete recode of major functionsv2.4.0
Diffstat (limited to 'lib/MasterServer/Database/Pg/dbMaintenance.pm')
-rwxr-xr-xlib/MasterServer/Database/Pg/dbMaintenance.pm19
1 files changed, 6 insertions, 13 deletions
diff --git a/lib/MasterServer/Database/Pg/dbMaintenance.pm b/lib/MasterServer/Database/Pg/dbMaintenance.pm
index 7a4fc23..f6c39b7 100755
--- a/lib/MasterServer/Database/Pg/dbMaintenance.pm
+++ b/lib/MasterServer/Database/Pg/dbMaintenance.pm
@@ -3,7 +3,6 @@ package MasterServer::Database::Pg::dbMaintenance;
use strict;
use warnings;
use Exporter 'import';
-
our @EXPORT = qw| delete_old_pending
remove_pending |;
@@ -12,14 +11,10 @@ our @EXPORT = qw| delete_old_pending
## where the server is unresponsive for more than 1 hour
################################################################################
sub delete_old_pending {
- my ($self) = shift;
-
- # remove servers
+ my $self = shift;
my $u = $self->{dbh}->do(
"DELETE FROM pending
WHERE added < to_timestamp(?)", undef, time-3600);
-
- # notify
$self->log("delete", "Removed $u entries from pending.") if ($u > 0);
}
@@ -28,13 +23,11 @@ sub delete_old_pending {
## of error(s).
################################################################################
sub remove_pending {
- my ($self, $id) = @_;
-
- # if address is in list, update the timestamp
- my $u = $self->{dbh}->do("DELETE FROM pending WHERE id = ?", undef, $id);
-
- # notify
- $self->log("delete", "removed pending id $id from pending") if ($u > 0);
+ my $self = shift;
+ my %o = ( @_);
+ my $u = $self->{dbh}->do("DELETE FROM pending WHERE ip = ? AND heartbeat = ?",
+ undef, $o{ip}, $o{port});
+ $self->log("delete", "removed $o{ip}, $o{port} from pending (".$u."x)") if ($u > 0);
}
1;