Skip to content

Commit

Permalink
Fix data race in sandbox serve
Browse files Browse the repository at this point in the history
Signed-off-by: Vladimir Popov <vladimir.popov@xored.com>
  • Loading branch information
Vladimir Popov committed Apr 22, 2021
1 parent ea8357e commit 55e14e6
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion pkg/tools/sandbox/grpc_utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,10 +38,12 @@ func serve(ctx context.Context, t *testing.T, u *url.URL, register func(server *
register(server)

errCh := grpcutils.ListenAndServe(ctx, u, server)
urlString := u.String()
go func() {
select {
case <-ctx.Done():
log.FromContext(ctx).Infof("Stop serve: %v", u.String())
// At this moment url can be updated, so we need `urlString`.
log.FromContext(ctx).Infof("Stop serve: %v", urlString)
return
case err := <-errCh:
require.NoError(t, err)
Expand Down

0 comments on commit 55e14e6

Please sign in to comment.