-
Notifications
You must be signed in to change notification settings - Fork 4.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
server: fix race between GracefulStop and new incoming connections (#1745) #1745
Conversation
8dda4ab
to
0e0c605
Compare
"context" was imported by |
test/gracefulstop_test.go
Outdated
}() | ||
|
||
fmt.Println("calling RPC") | ||
time.Sleep(time.Second) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why do we sleep here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Accidental leftover from debugging. Also removed lots of fmt.Print
s
server.go
Outdated
@@ -511,7 +516,8 @@ func (s *Server) Serve(lis net.Listener) error { | |||
timer := time.NewTimer(tempDelay) | |||
select { | |||
case <-timer.C: | |||
case <-s.ctx.Done(): | |||
case <-s.quit: | |||
return nil | |||
} | |||
timer.Stop() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not in your PR but we can get rid of this time.Stop() now that we're here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Moved to the appropriate place.
server.go
Outdated
if !s.addConn(conn) { | ||
conn.Close() | ||
return | ||
} | ||
defer s.removeConn(conn) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Shouldn't this be deleted too?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, thanks - done.
Fixes #1737
Updates #1738