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 { select {
case <-playlistFired: case <-playlistFired:
lastPlayedCacheMutex.Lock() lastPlayedCacheMutex.Lock()
defer lastPlayedCacheMutex.Unlock()
songs, err := lastPlayedSongs(lastNSongs, playlistPath) songs, err := lastPlayedSongs(lastNSongs, playlistPath)
if err == nil && len(songs) > 0 { if err == nil && len(songs) > 0 {
lastPlayedCache = songs lastPlayedCache = songs
} }
lastPlayedCacheMutex.Unlock()
} }
} }
}() }()