From 86e0a7c0de5300f8e72a8f1d70fbb59080d31fe9 Mon Sep 17 00:00:00 2001 From: Damyan Ivanov Date: Sat, 13 Nov 2021 07:43:55 +0000 Subject: [PATCH] subscribe to "close" event only once, after connecting to mpd --- lib/App/MPD/Feeder.pm | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) 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; } -- 2.39.5