Improve concurrency and resource management #2

Merged
bagas merged 12 commits from staging into main 2025-07-23 06:51:09 +00:00
Showing only changes of commit 32f9765374 - Show all commits

View File

@ -48,7 +48,6 @@ type Session struct {
ForwardedPort uint16
Status SessionStatus
Slug string
SlugChannel chan bool
Done chan bool
}
@ -554,7 +553,7 @@ func (s *Session) HandleForwardedConnection(conn UserConnection, sshConn *ssh.Se
}
defer channel.Close()
go handleChannelRequests(reqs, conn, channel, s.SlugChannel)
go handleChannelRequests(reqs, conn, channel)
if conn.Reader == nil {
conn.Reader = bufio.NewReader(conn.Writer)
@ -577,7 +576,7 @@ func (s *Session) HandleForwardedConnection(conn UserConnection, sshConn *ssh.Se
io.Copy(conn.Writer, reader)
}
func handleChannelRequests(reqs <-chan *ssh.Request, conn UserConnection, channel ssh.Channel, slugChannel <-chan bool) {
func handleChannelRequests(reqs <-chan *ssh.Request, conn UserConnection, channel ssh.Channel) {
select {
case <-reqs:
for req := range reqs {
@ -588,11 +587,6 @@ func handleChannelRequests(reqs <-chan *ssh.Request, conn UserConnection, channe
channel.Close()
log.Println("Connection closed by timeout")
return
case <-slugChannel:
conn.Writer.Close()
channel.Close()
log.Println("Connection closed by slug change")
return
}
}