commit b81665c76e6ad297b384f048ae84e86a2a7655f5
parent 8b1b4459232672f6b4286fead7748c5d0680e7d7
Author: Matsuda Kenji <info@mtkn.jp>
Date: Thu, 4 Jan 2024 08:51:32 +0900
fix goroutin leak
Diffstat:
1 file changed, 2 insertions(+), 0 deletions(-)
diff --git a/server.go b/server.go
@@ -1164,6 +1164,8 @@ func sWStat(ctx context.Context, c *conn, rc <-chan *request) {
// So some additional struct to represent each connection is needed.
// And Serve method should be attached to that struct.
func (s *Server) Serve(ctx context.Context, r io.Reader, w io.Writer) {
+ ctx, cancel := context.WithCancel(ctx)
+ defer cancel()
rp := newReqPool()
c := s.newConn(r, w)
c.runListener(ctx, rp)