1
0

Fixed deadlock caused by misunderstanding of how defer works.

This commit is contained in:
Alexander Andreev 2022-04-01 21:12:54 +04:00
parent 21995ea4cd
commit 1ed81fdd36
Signed by: Arav
GPG Key ID: 1327FE8A374CC86F

View File

@ -152,11 +152,11 @@ func IcecastWatchPlaylist(playlistPath string, lastNSongs int) error {
select {
case <-playlistFired:
lastPlayedCacheMutex.Lock()
defer lastPlayedCacheMutex.Unlock()
songs, err := lastPlayedSongs(lastNSongs, playlistPath)
if err == nil && len(songs) > 0 {
lastPlayedCache = songs
}
lastPlayedCacheMutex.Unlock()
}
}
}()