mirror of
https://github.com/golang/go.git
synced 2025-12-08 06:10:04 +00:00
net/rpc: don't exit if Accept gets an error
The default implementation of Accept, which spins up a new server for every new connection, calls log.Fatal if the listener is closed, stopping any outstanding work. Change that to a non-fatal log call so work can continue. There is no programmatic signaling of the problem, just the log, but that should be enough. Fixes #11221. Change-Id: I7c7f6164a0a0143236729eb778d7638c51c34ed1 Reviewed-on: https://go-review.googlesource.com/14185 Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
This commit is contained in:
parent
d5e32ebf54
commit
37025536c3
2 changed files with 18 additions and 3 deletions
|
|
@ -611,13 +611,15 @@ func (server *Server) readRequestHeader(codec ServerCodec) (service *service, mt
|
|||
}
|
||||
|
||||
// Accept accepts connections on the listener and serves requests
|
||||
// for each incoming connection. Accept blocks; the caller typically
|
||||
// invokes it in a go statement.
|
||||
// for each incoming connection. Accept blocks until the listener
|
||||
// returns a non-nil error. The caller typically invokes Accept in a
|
||||
// go statement.
|
||||
func (server *Server) Accept(lis net.Listener) {
|
||||
for {
|
||||
conn, err := lis.Accept()
|
||||
if err != nil {
|
||||
log.Fatal("rpc.Serve: accept:", err.Error()) // TODO(r): exit?
|
||||
log.Print("rpc.Serve: accept:", err.Error())
|
||||
return
|
||||
}
|
||||
go server.ServeConn(conn)
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue