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:
Michael Crosby 2018-08-30 11:40:42 -04:00
parent d77f111e2e
commit 33564d24b2
2 changed files with 2 additions and 2 deletions

View File

@ -1,6 +1,6 @@
language: go
go:
- 1.9.x
- "1.10.x"
script: go test -race -v ./...

View File

@ -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)