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.
This commit is contained in:
Felix Lange
2018-04-18 12:27:20 +02:00
committed by GitHub
parent 661f5f3dac
commit 52b046c9b6
6 changed files with 23 additions and 54 deletions

View File

@ -303,23 +303,13 @@ func (n *Node) stopInProc() {
// startIPC initializes and starts the IPC RPC endpoint.
func (n *Node) startIPC(apis []rpc.API) error {
// Short circuit if the IPC endpoint isn't being exposed
if n.ipcEndpoint == "" {
return nil
return nil // IPC disabled.
}
isClosed := func() bool {
n.lock.RLock()
defer n.lock.RUnlock()
return n.ipcListener == nil
}
listener, handler, err := rpc.StartIPCEndpoint(isClosed, n.ipcEndpoint, apis)
listener, handler, err := rpc.StartIPCEndpoint(n.ipcEndpoint, apis)
if err != nil {
return err
}
// All listeners booted successfully
n.ipcListener = listener
n.ipcHandler = handler
n.log.Info("IPC endpoint opened", "url", n.ipcEndpoint)