diff options
| author | Taras Madan <tarasmadan@google.com> | 2026-01-21 20:00:38 +0100 |
|---|---|---|
| committer | Taras Madan <tarasmadan@google.com> | 2026-01-21 22:46:06 +0000 |
| commit | a16aed1db22739e7dea8098c79bc1963b871b5ec (patch) | |
| tree | ac3968a697f9cbe78c66915abe2a8d00e58a787b /pkg/flatrpc | |
| parent | 7ee46ad36cdaae818f74dea493b5ec30df3fe31b (diff) | |
all: fix context.Context usage
Diffstat (limited to 'pkg/flatrpc')
| -rw-r--r-- | pkg/flatrpc/conn.go | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/pkg/flatrpc/conn.go b/pkg/flatrpc/conn.go index 47b265493..e8ad1461f 100644 --- a/pkg/flatrpc/conn.go +++ b/pkg/flatrpc/conn.go @@ -45,11 +45,11 @@ func Listen(addr string) (*Serv, error) { // Serve accepts incoming connections and calls handler for each of them. // An error returned from the handler stops the server and aborts the whole processing. -func (s *Serv) Serve(baseCtx context.Context, handler func(context.Context, *Conn) error) error { - eg, ctx := errgroup.WithContext(baseCtx) +func (s *Serv) Serve(ctx context.Context, handler func(context.Context, *Conn) error) error { + eg, groupCtx := errgroup.WithContext(ctx) go func() { // If the context is cancelled, stop the server. - <-ctx.Done() + <-groupCtx.Done() s.Close() }() for { @@ -66,7 +66,7 @@ func (s *Serv) Serve(baseCtx context.Context, handler func(context.Context, *Con continue } eg.Go(func() error { - connCtx, cancel := context.WithCancel(ctx) + connCtx, cancel := context.WithCancel(groupCtx) defer cancel() c := NewConn(conn) |
