diff options
| author | Adnan Maolood <[email protected]> | 2021-02-21 00:41:39 -0500 |
|---|---|---|
| committer | Adnan Maolood <[email protected]> | 2021-02-21 00:41:41 -0500 |
| commit | 3fa55b52dd843266a0352b020d2e789aef1184e7 (patch) | |
| tree | 74b2267b9d1ce0c6c6919063caa14d7c715c07de /server.go | |
| parent | examples/stream: Showcase Server.Shutdown method (diff) | |
| download | go-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.go | 6 |
1 files changed, 3 insertions, 3 deletions
@@ -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 } |