Skip to content

Commit 9bd804f

Browse files
authored
Merge branch 'master' into resolve-race
2 parents d18203f + 8d8dddd commit 9bd804f

File tree

2 files changed

+24
-26
lines changed

2 files changed

+24
-26
lines changed

.github/workflows/ci.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ jobs:
99
runs-on: ubuntu-latest
1010
steps:
1111
- uses: actions/checkout@v3
12-
- uses: actions/setup-go@v3
12+
- uses: actions/setup-go@v4
1313
with:
1414
go-version-file: ./go.mod
1515
cache: true

xhttp/serve.go

+23-25
Original file line numberDiff line numberDiff line change
@@ -65,28 +65,26 @@ func Serve(ctx context.Context, shutdownTimeout time.Duration, s *http.Server, l
6565
return ctx
6666
}
6767

68-
ss := newSafeServer(s)
69-
70-
serverClosed := make(chan struct{})
71-
var serverError error
72-
go func() {
73-
serverError = ss.ListenAndServe(l)
74-
close(serverClosed)
75-
}()
76-
77-
select {
78-
case <-serverClosed:
79-
return serverError
80-
case <-ctx.Done():
81-
shutdownCtx, cancel := context.WithTimeout(xcontext.WithoutCancel(ctx), shutdownTimeout)
82-
defer cancel()
83-
84-
err := ss.Shutdown(shutdownCtx)
85-
<-serverClosed // Wait for server to exit
86-
if err != nil {
87-
return err
88-
}
89-
return serverError
90-
}
91-
92-
}
68+
ss := newSafeServer(s)
69+
70+
serverClosed := make(chan struct{})
71+
var serverError error
72+
go func() {
73+
serverError = ss.ListenAndServe(l)
74+
close(serverClosed)
75+
}()
76+
77+
select {
78+
case <-serverClosed:
79+
return serverError
80+
case <-ctx.Done():
81+
shutdownCtx, cancel := context.WithTimeout(xcontext.WithoutCancel(ctx), shutdownTimeout)
82+
defer cancel()
83+
err := ss.Shutdown(shutdownCtx)
84+
<-serverClosed // Wait for server to exit
85+
if err != nil {
86+
return err
87+
}
88+
return serverError
89+
}
90+
}

0 commit comments

Comments
 (0)