diff options
author | Péter Szilágyi <peterke@gmail.com> | 2015-09-11 22:03:31 +0800 |
---|---|---|
committer | Péter Szilágyi <peterke@gmail.com> | 2015-09-11 22:03:31 +0800 |
commit | 3e6964b841bb22c4eab4cdaa22655beeae577419 (patch) | |
tree | fa1580b52213ec87a9cddc89e087ab8865a5f105 /rpc/comms | |
parent | 4e075e401354b4ee068cf78b1f283763fe927245 (diff) | |
download | dexon-3e6964b841bb22c4eab4cdaa22655beeae577419.tar dexon-3e6964b841bb22c4eab4cdaa22655beeae577419.tar.gz dexon-3e6964b841bb22c4eab4cdaa22655beeae577419.tar.bz2 dexon-3e6964b841bb22c4eab4cdaa22655beeae577419.tar.lz dexon-3e6964b841bb22c4eab4cdaa22655beeae577419.tar.xz dexon-3e6964b841bb22c4eab4cdaa22655beeae577419.tar.zst dexon-3e6964b841bb22c4eab4cdaa22655beeae577419.zip |
rpc/comms: fix #1795, ensure IPC path exists before binding
Diffstat (limited to 'rpc/comms')
-rw-r--r-- | rpc/comms/ipc_unix.go | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/rpc/comms/ipc_unix.go b/rpc/comms/ipc_unix.go index 9d90da071..d68363a45 100644 --- a/rpc/comms/ipc_unix.go +++ b/rpc/comms/ipc_unix.go @@ -21,6 +21,7 @@ package comms import ( "net" "os" + "path/filepath" "github.com/ethereum/go-ethereum/logger" "github.com/ethereum/go-ethereum/logger/glog" @@ -69,7 +70,11 @@ func (self *ipcClient) reconnect() error { } func startIpc(cfg IpcConfig, codec codec.Codec, initializer func(conn net.Conn) (shared.EthereumApi, error)) error { - os.Remove(cfg.Endpoint) // in case it still exists from a previous run + // Ensure the IPC path exists and remove any previous leftover + if err := os.MkdirAll(filepath.Dir(cfg.Endpoint), 0751); err != nil { + return err + } + os.Remove(cfg.Endpoint) l, err := net.ListenUnix("unix", &net.UnixAddr{Name: cfg.Endpoint, Net: "unix"}) if err != nil { |