From 1ed81fdd366a9f6f99861b9c85d037a10b243509 Mon Sep 17 00:00:00 2001 From: "Alexander \"Arav\" Andreev" Date: Fri, 1 Apr 2022 21:12:54 +0400 Subject: [PATCH] Fixed deadlock caused by misunderstanding of how defer works. --- internal/radio/icecast.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/internal/radio/icecast.go b/internal/radio/icecast.go index 7fe8c2c..ded957a 100644 --- a/internal/radio/icecast.go +++ b/internal/radio/icecast.go @@ -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() } } }()