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 {
|
extension MPDClient {
|
||||||
func noIdle() {
|
func noIdle() {
|
||||||
if isIdle {
|
do {
|
||||||
do {
|
idleLock.lock()
|
||||||
idleLock.lock()
|
defer { idleLock.unlock() }
|
||||||
defer { idleLock.unlock() }
|
if isIdle {
|
||||||
mpd_send_noidle(connection)
|
mpd_send_noidle(connection)
|
||||||
isIdle = false
|
isIdle = false
|
||||||
}
|
}
|
||||||
@ -22,14 +22,21 @@ extension MPDClient {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func idle(_ force: Bool = false) {
|
func idle(_ force: Bool = false) {
|
||||||
if (!self.isIdle && self.commandQueue.operationCount == 1) || force {
|
let shouldIdle: Bool
|
||||||
do {
|
|
||||||
idleLock.lock()
|
do {
|
||||||
defer { idleLock.unlock() }
|
idleLock.lock()
|
||||||
|
defer { idleLock.unlock() }
|
||||||
|
shouldIdle = (!self.isIdle && self.commandQueue.operationCount == 1) || force
|
||||||
|
if shouldIdle {
|
||||||
mpd_send_idle(self.connection)
|
mpd_send_idle(self.connection)
|
||||||
self.isIdle = true
|
self.isIdle = true
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// noIdle could happen here which will crash
|
||||||
|
|
||||||
|
if shouldIdle {
|
||||||
let result = mpd_recv_idle(self.connection, true)
|
let result = mpd_recv_idle(self.connection, true)
|
||||||
self.handleIdleResult(result)
|
self.handleIdleResult(result)
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user