mirror of
https://github.com/danbee/persephone
synced 2025-03-04 08:39:11 +00:00
Woops, we were reading this outside of the lock!
This commit is contained in:
parent
fa338ee790
commit
2f59eaeecf
@ -11,10 +11,10 @@ import mpdclient
|
||||
|
||||
extension MPDClient {
|
||||
func noIdle() {
|
||||
if isIdle {
|
||||
do {
|
||||
idleLock.lock()
|
||||
defer { idleLock.unlock() }
|
||||
if isIdle {
|
||||
mpd_send_noidle(connection)
|
||||
isIdle = false
|
||||
}
|
||||
@ -22,14 +22,21 @@ extension MPDClient {
|
||||
}
|
||||
|
||||
func idle(_ force: Bool = false) {
|
||||
if (!self.isIdle && self.commandQueue.operationCount == 1) || force {
|
||||
let shouldIdle: Bool
|
||||
|
||||
do {
|
||||
idleLock.lock()
|
||||
defer { idleLock.unlock() }
|
||||
shouldIdle = (!self.isIdle && self.commandQueue.operationCount == 1) || force
|
||||
if shouldIdle {
|
||||
mpd_send_idle(self.connection)
|
||||
self.isIdle = true
|
||||
}
|
||||
}
|
||||
|
||||
// noIdle could happen here which will crash
|
||||
|
||||
if shouldIdle {
|
||||
let result = mpd_recv_idle(self.connection, true)
|
||||
self.handleIdleResult(result)
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user