diff options
author | Felix Lange <fjl@users.noreply.github.com> | 2018-04-18 18:27:20 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-04-18 18:27:20 +0800 |
commit | 52b046c9b6a0f6a280ff797f90784f76bfd310b9 (patch) | |
tree | 709ce3f7e873e47bdac72ab4f9935cf7b3108c4b /rpc/ipc.go | |
parent | 661f5f3dac23939630e3bf2f9ed2bf1bfb26e990 (diff) | |
download | go-tangerine-52b046c9b6a0f6a280ff797f90784f76bfd310b9.tar go-tangerine-52b046c9b6a0f6a280ff797f90784f76bfd310b9.tar.gz go-tangerine-52b046c9b6a0f6a280ff797f90784f76bfd310b9.tar.bz2 go-tangerine-52b046c9b6a0f6a280ff797f90784f76bfd310b9.tar.lz go-tangerine-52b046c9b6a0f6a280ff797f90784f76bfd310b9.tar.xz go-tangerine-52b046c9b6a0f6a280ff797f90784f76bfd310b9.tar.zst go-tangerine-52b046c9b6a0f6a280ff797f90784f76bfd310b9.zip |
rpc: clean up IPC handler (#16524)
This avoids logging accept errors on shutdown and removes
a bit of duplication. It also fixes some goimports lint warnings.
Diffstat (limited to 'rpc/ipc.go')
-rw-r--r-- | rpc/ipc.go | 15 |
1 files changed, 6 insertions, 9 deletions
diff --git a/rpc/ipc.go b/rpc/ipc.go index 8de18a56f..b05e503d7 100644 --- a/rpc/ipc.go +++ b/rpc/ipc.go @@ -18,26 +18,23 @@ package rpc import ( "context" - "fmt" "net" "github.com/ethereum/go-ethereum/log" + "github.com/ethereum/go-ethereum/p2p/netutil" ) -// CreateIPCListener creates an listener, on Unix platforms this is a unix socket, on -// Windows this is a named pipe -func CreateIPCListener(endpoint string) (net.Listener, error) { - return ipcListen(endpoint) -} - // ServeListener accepts connections on l, serving JSON-RPC on them. func (srv *Server) ServeListener(l net.Listener) error { for { conn, err := l.Accept() - if err != nil { + if netutil.IsTemporaryError(err) { + log.Warn("RPC accept error", "err", err) + continue + } else if err != nil { return err } - log.Trace(fmt.Sprint("accepted conn", conn.RemoteAddr())) + log.Trace("Accepted connection", "addr", conn.RemoteAddr()) go srv.ServeCodec(NewJSONCodec(conn), OptionMethodInvocation|OptionSubscriptions) } } |