From 6c0b3b795272fa9bdf0ab2104fd68c49611941df Mon Sep 17 00:00:00 2001 From: Bruno Morais Date: Tue, 10 Sep 2019 11:09:03 -0400 Subject: [PATCH] handle bus timeout properly --- src/plugins/mpris/mpris.cpp | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/src/plugins/mpris/mpris.cpp b/src/plugins/mpris/mpris.cpp index acd5a3b2b..cf31003cb 100644 --- a/src/plugins/mpris/mpris.cpp +++ b/src/plugins/mpris/mpris.cpp @@ -89,10 +89,9 @@ bool MPRISRemote::MPRISInit() { } void MPRISRemote::MPRISDeinit() { - if (this->bus) { - sd_bus_unref(this->bus); - bus = NULL; - } + + sd_bus_close_unref(this->bus); + bus = NULL; stop_processing = true; if (thread) { thread->join(); @@ -125,9 +124,11 @@ void MPRISRemote::MPRISLoop() { while (!stop_processing) { if (bus) { if (sd_bus_process(bus, NULL) > 0) { - continue; + continue; + } + if (sd_bus_wait(bus, 500*1000) < 0) { + break; } - sd_bus_wait(bus, (uint64_t)-1); } } }