vishen / go-chromecast

cli for Google Chromecast, Home devices and Cast Groups
Apache License 2.0
853 stars 84 forks source link

fix: Fix Goroutine leak after calling Close #166

Closed gabe565 closed 1 year ago

gabe565 commented 1 year ago

Hello!

go-chromecast is an amazing tool. I am writing a Go implementation of sponsorblockcast called CastSponsorSkip and have noticed if a device disconnects and I call Application.Close(), some Goroutines never exit resulting in a slight memory leak.

The problematic functions are:

This PR closes those channels when Application.Close() and Connection.Close() are called. I opted to close the channels in a defer so that they stay open while the underlying connection is closed. Let me know if you have any feedback!

vishen commented 1 year ago

Ah, thanks @gabe565, good catch! PR looks good :)