mirror of
https://github.com/pragma-/pbot.git
synced 2024-11-19 10:29:30 +01:00
Fix "unable to close filehandle __ANONIO__ properly" warning
This commit is contained in:
parent
f504a5e2ff
commit
c7b2386ff6
@ -51,8 +51,15 @@ sub sqlite_commit_interval_trigger {
|
||||
|
||||
sub sqlite_debug_trigger {
|
||||
my ($self, $section, $item, $newvalue) = @_;
|
||||
$self->{dbh}->trace($self->{dbh}->parse_trace_flags("SQL|$newvalue")) if defined $self->{dbh};
|
||||
|
||||
if ($newvalue) {
|
||||
open $self->{trace_layer}, '>:via(PBot::SQLiteLoggerLayer)', PBot::SQLiteLogger->new(pbot => $self->{pbot});
|
||||
} else {
|
||||
close $self->{trace_layer} if $self->{trace_layer};
|
||||
delete $self->{trace_layer};
|
||||
}
|
||||
|
||||
$self->{dbh}->trace($self->{dbh}->parse_trace_flags("SQL|$newvalue")) if defined $self->{dbh};
|
||||
}
|
||||
|
||||
sub begin {
|
||||
@ -67,8 +74,10 @@ sub begin {
|
||||
my $sqlite_debug = $self->{pbot}->{registry}->get_value('messagehistory', 'sqlite_debug');
|
||||
use PBot::SQLiteLoggerLayer;
|
||||
use PBot::SQLiteLogger;
|
||||
if ($sqlite_debug) {
|
||||
open $self->{trace_layer}, '>:via(PBot::SQLiteLoggerLayer)', PBot::SQLiteLogger->new(pbot => $self->{pbot});
|
||||
$self->{dbh}->trace($self->{dbh}->parse_trace_flags("SQL|$sqlite_debug"), $self->{trace_layer});
|
||||
}
|
||||
|
||||
$self->{dbh}->do(<<SQL);
|
||||
CREATE TABLE IF NOT EXISTS Hostmasks (
|
||||
@ -165,6 +174,7 @@ sub end {
|
||||
if (exists $self->{dbh} and defined $self->{dbh}) {
|
||||
$self->{dbh}->commit() if $self->{new_entries};
|
||||
$self->{dbh}->disconnect();
|
||||
close $self->{trace_layer} if $self->{trace_layer};
|
||||
delete $self->{dbh};
|
||||
}
|
||||
}
|
||||
|
12
PBot/PBot.pm
12
PBot/PBot.pm
@ -100,16 +100,16 @@ sub initialize {
|
||||
}
|
||||
}
|
||||
|
||||
# let modules register signal handlers
|
||||
$self->{atexit} = PBot::Registerable->new(%conf, pbot => $self);
|
||||
$self->register_signal_handlers;
|
||||
|
||||
# make sure the data directory exists
|
||||
if (not -d $data_dir) {
|
||||
print STDERR "Data directory ($data_dir) does not exist; aborting...\n";
|
||||
exit;
|
||||
}
|
||||
|
||||
# let modules register signal handlers
|
||||
$self->{atexit} = PBot::Registerable->new(%conf, pbot => $self);
|
||||
$self->register_signal_handlers;
|
||||
|
||||
# create logger
|
||||
$self->{logger} = PBot::Logger->new(pbot => $self, filename => "$data_dir/log/log", %conf);
|
||||
|
||||
@ -411,9 +411,9 @@ sub cmd_sl {
|
||||
sub cmd_die {
|
||||
my ($self, $context) = @_;
|
||||
$self->{logger}->log("$context->{hostmask} made me exit.\n");
|
||||
$self->atexit();
|
||||
$self->{conn}->privmsg($context->{from}, "Good-bye.") if defined $context->{from};
|
||||
$self->{conn}->privmsg($context->{from}, "Good-bye.") if $context->{from} ne 'stdin@pbot';
|
||||
$self->{conn}->quit("Departure requested.") if defined $self->{conn};
|
||||
$self->atexit();
|
||||
exit 0;
|
||||
}
|
||||
|
||||
|
@ -210,6 +210,7 @@ sub execute_process {
|
||||
# print $context to pipe
|
||||
my $json = encode_json $context;
|
||||
print $writer "$json\n";
|
||||
close $writer;
|
||||
|
||||
# end child
|
||||
exit 0;
|
||||
@ -225,6 +226,7 @@ sub execute_process {
|
||||
|
||||
sub process_pipe_reader {
|
||||
my ($self, $pid, $buf) = @_;
|
||||
|
||||
my $context = decode_json $buf or do {
|
||||
$self->{pbot}->{logger}->log("Failed to decode bad json: [$buf]\n");
|
||||
return;
|
||||
|
Loading…
Reference in New Issue
Block a user