Skip to content

Commit

Permalink
bug fix: do not access RemoteAddr on nil net.Conn
Browse files Browse the repository at this point in the history
  • Loading branch information
iamqizhao committed Sep 25, 2015
1 parent 60c363f commit efb129e
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions server.go
Original file line number Diff line number Diff line change
Expand Up @@ -229,14 +229,16 @@ func (s *Server) Serve(lis net.Listener) error {
}
var authInfo credentials.AuthInfo
if creds, ok := s.opts.creds.(credentials.TransportAuthenticator); ok {
c, authInfo, err = creds.ServerHandshake(c)
var conn net.Conn
conn, authInfo, err = creds.ServerHandshake(c)
if err != nil {
s.mu.Lock()
s.errorf("ServerHandshake failed: %v", err)
s.errorf("ServerHandshake failed: %v", c.RemoteAddr(), err)
s.mu.Unlock()
grpclog.Println("grpc: Server.Serve failed to complete security handshake.")
continue
}
c = conn
}
s.mu.Lock()
if s.conns == nil {
Expand Down

0 comments on commit efb129e

Please sign in to comment.