Fix leaky channels hopefully.

This commit is contained in:
Andrey Petrov 2014-12-12 12:19:39 -08:00
parent 0b80aa8345
commit 8f408b7674
3 changed files with 8 additions and 13 deletions

View File

@ -55,5 +55,3 @@ things up with `make run`.
* [ ] Lots of refactoring
* [ ] Pull out the chat-related stuff into isolation from the ssh serving
stuff
* Fix hanging on collision connect

View File

@ -88,7 +88,14 @@ func (c *Client) Rename(name string) {
func (c *Client) handleShell(channel ssh.Channel) {
defer channel.Close()
c.ready <- struct{}{}
// FIXME: This shouldn't live here, need to restructure the call chaining.
c.Server.Add(c)
go func() {
// Block until done, then remove.
c.Conn.Wait()
c.Server.Remove(c)
}()
go func() {
for msg := range c.Msg {

View File

@ -195,16 +195,6 @@ func (s *Server) Start(laddr string) error {
client := NewClient(s, sshConn)
go client.handleChannels(channels)
// FIXME: This is hacky, need to restructure the concurrency. Fairly sure this will leak channels.
<-client.ready
s.Add(client)
go func() {
// Block until done, then remove.
sshConn.Wait()
s.Remove(client)
}()
}()
}
}()