bug: fix issues w/ closed connection not closing running process

This commit is contained in:
Will Owens 2025-10-26 08:58:19 -05:00
parent 71b9db14e2
commit c830287cb0
No known key found for this signature in database
GPG key ID: 8C8384B16B623DA6
4 changed files with 12 additions and 8 deletions

View file

@ -72,7 +72,7 @@ func (server *Server) generateHandleWS(ctx context.Context, cancel context.Cance
}
defer conn.Close()
err = server.processWSConn(ctx, conn)
err = server.processWSConn(r.Context(), conn)
switch err {
case ctx.Err():
@ -117,7 +117,7 @@ func (server *Server) processWSConn(ctx context.Context, conn *websocket.Conn) e
params := query.Query()
var slave Slave
slave, err = server.factory.New(params, conn)
slave, err = server.factory.New(ctx, params, conn)
if err != nil {
return errors.Wrapf(err, "failed to create backend")
}

View file

@ -1,6 +1,8 @@
package server
import (
"context"
"github.com/ghthor/gotty/v2/webtty"
"github.com/gorilla/websocket"
@ -15,5 +17,5 @@ type Slave interface {
type Factory interface {
Name() string
New(params map[string][]string, conn *websocket.Conn) (Slave, error)
New(ctx context.Context, params map[string][]string, conn *websocket.Conn) (Slave, error)
}