aboutsummaryrefslogtreecommitdiff
path: root/server.go
diff options
context:
space:
mode:
authorAdnan Maolood <[email protected]>2021-02-21 00:41:39 -0500
committerAdnan Maolood <[email protected]>2021-02-21 00:41:41 -0500
commit3fa55b52dd843266a0352b020d2e789aef1184e7 (patch)
tree74b2267b9d1ce0c6c6919063caa14d7c715c07de /server.go
parentexamples/stream: Showcase Server.Shutdown method (diff)
downloadgo-gemini-3fa55b52dd843266a0352b020d2e789aef1184e7.tar.xz
go-gemini-3fa55b52dd843266a0352b020d2e789aef1184e7.zip
server: Use separate context to cancel listeners
Use a separate context to cancel listeners so that cancelling the listener does not cancel it's connections.
Diffstat (limited to 'server.go')
-rw-r--r--server.go6
1 files changed, 3 insertions, 3 deletions
diff --git a/server.go b/server.go
index 491f516..69a8b22 100644
--- a/server.go
+++ b/server.go
@@ -205,7 +205,7 @@ func (srv *Server) Serve(ctx context.Context, l net.Listener) error {
return ErrServerClosed
}
- ctx, cancel := context.WithCancel(ctx)
+ lnctx, cancel := context.WithCancel(ctx)
defer cancel()
srv.trackListener(&l, cancel)
@@ -218,8 +218,8 @@ func (srv *Server) Serve(ctx context.Context, l net.Listener) error {
}()
select {
- case <-ctx.Done():
- return ctx.Err()
+ case <-lnctx.Done():
+ return lnctx.Err()
case err := <-errch:
return err
}