koding / kite

Micro-service framework in Go
https://godoc.org/github.com/koding/kite
MIT License
3.26k stars 300 forks source link

kite: don't leak sendHub goroutine when client's readLoop ends #188

Closed ppknap closed 7 years ago

ppknap commented 7 years ago

sockjsHandler creates a new kite.Client object for each sockjs.Session. Handler and session end their life when blocking readLoop() method returns. This means that created kite.Client is no longer needed. However, it can't be GC because sendHub() still waits for incoming data from readLoop() which, as was written above, already returned.

This change closes created kite.Client when it's no longer needed. Closing it will also stop sendHub() go-routine.