mirror of
https://github.com/cirruslabs/orchard.git
synced 2026-10-21 02:22:46 +02:00
Fix websocket.(*Conn).timeoutLoop goroutine leak (#329)
This commit is contained in:
@@ -27,6 +27,13 @@ func (controller *Controller) rpcPortForward(ctx *gin.Context) responder.Respond
|
||||
if err != nil {
|
||||
return responder.Error(err)
|
||||
}
|
||||
defer func() {
|
||||
// Ensure that we always close the accepted WebSocket connection,
|
||||
// otherwise resource leak is possible[1]
|
||||
//
|
||||
// [1]: https://github.com/coder/websocket/issues/445#issuecomment-2053792044
|
||||
_ = wsConn.CloseNow()
|
||||
}()
|
||||
|
||||
// Respond with the established connection
|
||||
proxyCtx, err := controller.connRendezvous.Respond(session, rendezvous.ResultWithErrorMessage[net.Conn]{
|
||||
|
||||
@@ -37,6 +37,13 @@ func (controller *Controller) rpcWatch(ctx *gin.Context) responder.Responder {
|
||||
if err != nil {
|
||||
return responder.Error(err)
|
||||
}
|
||||
defer func() {
|
||||
// Ensure that we always close the accepted WebSocket connection,
|
||||
// otherwise resource leak is possible[1]
|
||||
//
|
||||
// [1]: https://github.com/coder/websocket/issues/445#issuecomment-2053792044
|
||||
_ = wsConn.CloseNow()
|
||||
}()
|
||||
|
||||
// Ensure that pongs will be processed by reading
|
||||
// from the connection in the background
|
||||
|
||||
@@ -102,6 +102,13 @@ func (controller *Controller) portForward(
|
||||
if err != nil {
|
||||
return responder.Error(err)
|
||||
}
|
||||
defer func() {
|
||||
// Ensure that we always close the accepted WebSocket connection,
|
||||
// otherwise resource leak is possible[1]
|
||||
//
|
||||
// [1]: https://github.com/coder/websocket/issues/445#issuecomment-2053792044
|
||||
_ = wsConn.CloseNow()
|
||||
}()
|
||||
|
||||
expectedMsgType := websocket.MessageBinary
|
||||
|
||||
|
||||
Reference in New Issue
Block a user