blob: 06a8db49b8f1b7bfcceab913a9013ff6616e9ff2 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
|
package MasterServer::Database::SQLite::dbMaintenance;
use strict;
use warnings;
use Exporter 'import';
our @EXPORT = qw| delete_old_pending
remove_pending |;
################################################################################
## delete unresponsive servers from the pending list
## where the server is unresponsive for more than 1 hour
################################################################################
sub delete_old_pending {
my ($self) = shift;
# remove servers
my $u = $self->{dbh}->do(
"DELETE FROM pending
WHERE added < datetime(?, 'unixepoch')", undef, time-3600);
# notify
$self->log("delete", "Removed $u entries from pending.") if ($u > 0);
}
################################################################################
## Remove an entry from the pending list. Returns 0 if removed or -1 in case
## 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);
}
1;
|