mirror of
https://github.com/shazow/ssh-chat.git
synced 2025-04-23 04:00:31 +03:00
Fix leaky channels hopefully.
This commit is contained in:
parent
0b80aa8345
commit
8f408b7674
@ -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
|
||||
|
@ -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 {
|
||||
|
10
server.go
10
server.go
@ -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)
|
||||
}()
|
||||
}()
|
||||
}
|
||||
}()
|
||||
|
Loading…
x
Reference in New Issue
Block a user