From b0cfdfa257582e70421e985503ca1577264f5b9b Mon Sep 17 00:00:00 2001 From: Max Kellermann Date: Mon, 11 Mar 2024 14:59:45 +0100 Subject: [PATCH] client/Idle: consume only idle flags that were subscribed to Since the very beginning when idle subscriptions where introduced (commit 0bad84066bc12), waiting for a certain idle mask would clear all other idle flags as well. This would cause idle events to get lost. Closes https://github.com/MusicPlayerDaemon/MPD/issues/1998 --- NEWS | 1 + src/client/Idle.cxx | 6 ++++-- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/NEWS b/NEWS index f41ae404e..1eaa866c1 100644 --- a/NEWS +++ b/NEWS @@ -14,6 +14,7 @@ ver 0.24 (not yet released) - new "search"/"find" filter "added-since" - allow range in listplaylist and listplaylistinfo - "sticker find" supports sort and window parameter and new sticker compare operators "eq", "lt" and "gt" + - consume only idle flags that were subscribed to * database - attribute "added" shows when each song was added to the database - fix integer overflows with 64-bit inode numbers diff --git a/src/client/Idle.cxx b/src/client/Idle.cxx index 0a129eb2d..282dbab9f 100644 --- a/src/client/Idle.cxx +++ b/src/client/Idle.cxx @@ -26,9 +26,11 @@ void Client::IdleNotify() noexcept { assert(idle_waiting); - assert(idle_flags != 0); - unsigned flags = std::exchange(idle_flags, 0) & idle_subscriptions; + const unsigned flags = idle_flags & idle_subscriptions; + idle_flags &= ~idle_subscriptions; + assert(flags != 0); + idle_waiting = false; Response r(*this, 0);