From f19c4f4a5536346beca4d1d20cb9170621fe6c4c Mon Sep 17 00:00:00 2001 From: Kyle Carberry Date: Sun, 20 Feb 2022 13:48:14 -0600 Subject: [PATCH] Fix close writing even if context is cancelled In an HTTP handler where the context is used for cleanup, a goroutine would leak temporarily. By using the write context, it should block the WebSocket from sending the close frame at all if cancelled. --- close_notjs.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/close_notjs.go b/close_notjs.go index 4251311d..58a75efb 100644 --- a/close_notjs.go +++ b/close_notjs.go @@ -73,7 +73,7 @@ func (c *Conn) writeClose(code StatusCode, reason string) error { } } - writeErr := c.writeControl(context.Background(), opClose, p) + writeErr := c.writeControl(c.msgWriterState.ctx, opClose, p) if CloseStatus(writeErr) != -1 { // Not a real error if it's due to a close frame being received. writeErr = nil pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy