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
|
||||
|
||||
go:
|
||||
- 1.9.x
|
||||
- "1.10.x"
|
||||
|
||||
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 {
|
||||
s.mu.Lock()
|
||||
lnerr := s.closeListeners()
|
||||
select {
|
||||
case <-s.done:
|
||||
default:
|
||||
// protected by mutex
|
||||
close(s.done)
|
||||
}
|
||||
lnerr := s.closeListeners()
|
||||
s.mu.Unlock()
|
||||
|
||||
ticker := time.NewTicker(200 * time.Millisecond)
|
||||
|
Loading…
Reference in New Issue
Block a user