Signal server done before closing connections
This fixes the races we are seeing in the tests Signed-off-by: Michael Crosby <crosbymichael@gmail.com>
This commit is contained in:
parent
d77f111e2e
commit
33564d24b2
@ -1,6 +1,6 @@
|
|||||||
language: go
|
language: go
|
||||||
|
|
||||||
go:
|
go:
|
||||||
- 1.9.x
|
- "1.10.x"
|
||||||
|
|
||||||
script: go test -race -v ./...
|
script: go test -race -v ./...
|
||||||
|
@ -127,13 +127,13 @@ func (s *Server) Serve(ctx context.Context, l net.Listener) error {
|
|||||||
|
|
||||||
func (s *Server) Shutdown(ctx context.Context) error {
|
func (s *Server) Shutdown(ctx context.Context) error {
|
||||||
s.mu.Lock()
|
s.mu.Lock()
|
||||||
lnerr := s.closeListeners()
|
|
||||||
select {
|
select {
|
||||||
case <-s.done:
|
case <-s.done:
|
||||||
default:
|
default:
|
||||||
// protected by mutex
|
// protected by mutex
|
||||||
close(s.done)
|
close(s.done)
|
||||||
}
|
}
|
||||||
|
lnerr := s.closeListeners()
|
||||||
s.mu.Unlock()
|
s.mu.Unlock()
|
||||||
|
|
||||||
ticker := time.NewTicker(200 * time.Millisecond)
|
ticker := time.NewTicker(200 * time.Millisecond)
|
||||||
|
Loading…
Reference in New Issue
Block a user