Skip to content

Commit

Permalink
Fix an occasional panic caused by closing the channel before removing…
Browse files Browse the repository at this point in the history
… it from the list of listeners
  • Loading branch information
mmaelzer committed Dec 6, 2015
1 parent 8d40822 commit 05fb9f7
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion cam.go
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,6 @@ func (cam *Camera) Subscribe() (<-chan Frame, error) {
func (cam *Camera) Unsubscribe(unsub <-chan Frame) bool {
for i, l := range cam.listeners {
if unsub == l {
close(l)
if len(cam.listeners) == 1 {
cam.stop()
cam.listeners = make([]chan Frame, 0)
Expand All @@ -148,6 +147,7 @@ func (cam *Camera) Unsubscribe(unsub <-chan Frame) bool {
cam.listeners[i+1:]...,
)
}
close(l)
return true
}
}
Expand Down

0 comments on commit 05fb9f7

Please sign in to comment.