From: Damyan Ivanov Date: Sat, 13 Nov 2021 07:43:55 +0000 (+0000) Subject: subscribe to "close" event only once, after connecting to mpd X-Git-Url: https://git.ktnx.net/?a=commitdiff_plain;h=86e0a7c0de5300f8e72a8f1d70fbb59080d31fe9;p=mpd-feeder.git subscribe to "close" event only once, after connecting to mpd --- diff --git a/lib/App/MPD/Feeder.pm b/lib/App/MPD/Feeder.pm index 2381689..777c95b 100644 --- a/lib/App/MPD/Feeder.pm +++ b/lib/App/MPD/Feeder.pm @@ -61,6 +61,12 @@ use constant DEFAULT_CONFIG_FILE => '/etc/mpd-feeder/mpd-feeder.conf'; $mpd = Net::Async::MPD->new(%conn); + $mpd->on( + close => sub { + die "Connection to MPD lost"; + } + ); + my $int_signal_handler = sub { state $signal_count = 0; $signal_count++; @@ -242,11 +248,6 @@ use constant DEFAULT_CONFIG_FILE => '/etc/mpd-feeder/mpd-feeder.conf'; } method run { - $mpd->on( - close => sub { - die "Connection to MPD lost"; - } - ); $self->prepare_to_wait_idle; }