]> git.ktnx.net Git - mpd-feeder.git/commitdiff
subscribe to "close" event only once, after connecting to mpd
authorDamyan Ivanov <dmn@debian.org>
Sat, 13 Nov 2021 07:43:55 +0000 (07:43 +0000)
committerDamyan Ivanov <dmn@debian.org>
Sat, 13 Nov 2021 07:43:55 +0000 (07:43 +0000)
lib/App/MPD/Feeder.pm

index 2381689a20d4f6dd555b3c1e517562809568a555..777c95bf10d79b2b561ad57acd1437e4d605aa71 100644 (file)
@@ -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;
     }