Skip to content

Commit

Permalink
fix: double close on accesspoint recv channels
Browse files Browse the repository at this point in the history
  • Loading branch information
devgianlu committed Feb 5, 2024
1 parent 8a2cb3b commit 3858c64
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion ap/ap.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import (
"go-librespot/dh"
pb "go-librespot/proto/spotify"
"golang.org/x/crypto/pbkdf2"
"golang.org/x/exp/slices"
"google.golang.org/protobuf/proto"
"io"
"net"
Expand Down Expand Up @@ -286,9 +287,15 @@ loop:

ap.recvChansLock.RLock()
defer ap.recvChansLock.RUnlock()

var closedChannels []chan Packet
for _, ll := range ap.recvChans {
for _, ch := range ll {
close(ch)
// call close on each channel only once
if !slices.Contains(closedChannels, ch) {
closedChannels = append(closedChannels, ch)
close(ch)
}
}
}
}
Expand Down

0 comments on commit 3858c64

Please sign in to comment.