bug fix: do not access RemoteAddr on nil net.Conn

This commit is contained in:
iamqizhao 2015-09-24 18:41:56 -07:00
parent 60c363f984
commit efb129eb20
1 changed files with 4 additions and 2 deletions

View File

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