aboutsummaryrefslogtreecommitdiffstats
path: root/rpc/comms/ipc_unix.go
diff options
context:
space:
mode:
authorJeffrey Wilcke <geffobscura@gmail.com>2015-06-24 01:19:33 +0800
committerJeffrey Wilcke <geffobscura@gmail.com>2015-06-24 01:19:33 +0800
commit72e2613a9fe3205fa5a67b72b832e03b2357ee88 (patch)
treebbc987510d279d9e174ff8f684158d668131661e /rpc/comms/ipc_unix.go
parent5daf8729be88eca87b302ebf7a46fc69cad0f6d0 (diff)
parent67e6f74e9af00ff011a6a02f18644804eb18cdaa (diff)
downloaddexon-72e2613a9fe3205fa5a67b72b832e03b2357ee88.tar
dexon-72e2613a9fe3205fa5a67b72b832e03b2357ee88.tar.gz
dexon-72e2613a9fe3205fa5a67b72b832e03b2357ee88.tar.bz2
dexon-72e2613a9fe3205fa5a67b72b832e03b2357ee88.tar.lz
dexon-72e2613a9fe3205fa5a67b72b832e03b2357ee88.tar.xz
dexon-72e2613a9fe3205fa5a67b72b832e03b2357ee88.tar.zst
dexon-72e2613a9fe3205fa5a67b72b832e03b2357ee88.zip
Merge branch 'release/0.9.32'
Diffstat (limited to 'rpc/comms/ipc_unix.go')
-rw-r--r--rpc/comms/ipc_unix.go43
1 files changed, 13 insertions, 30 deletions
diff --git a/rpc/comms/ipc_unix.go b/rpc/comms/ipc_unix.go
index 5a94fd1e0..295eb916b 100644
--- a/rpc/comms/ipc_unix.go
+++ b/rpc/comms/ipc_unix.go
@@ -3,13 +3,11 @@
package comms
import (
- "io"
"net"
"os"
"github.com/ethereum/go-ethereum/logger"
"github.com/ethereum/go-ethereum/logger/glog"
- "github.com/ethereum/go-ethereum/rpc/api"
"github.com/ethereum/go-ethereum/rpc/codec"
"github.com/ethereum/go-ethereum/rpc/shared"
)
@@ -20,10 +18,20 @@ func newIpcClient(cfg IpcConfig, codec codec.Codec) (*ipcClient, error) {
return nil, err
}
- return &ipcClient{codec.New(c)}, nil
+ return &ipcClient{cfg.Endpoint, codec, codec.New(c)}, nil
}
-func startIpc(cfg IpcConfig, codec codec.Codec, api api.EthereumApi) error {
+func (self *ipcClient) reconnect() error {
+ self.coder.Close()
+ c, err := net.DialUnix("unix", nil, &net.UnixAddr{self.endpoint, "unix"})
+ if err == nil {
+ self.coder = self.codec.New(c)
+ }
+
+ return err
+}
+
+func startIpc(cfg IpcConfig, codec codec.Codec, api shared.EthereumApi) error {
os.Remove(cfg.Endpoint) // in case it still exists from a previous run
l, err := net.ListenUnix("unix", &net.UnixAddr{Name: cfg.Endpoint, Net: "unix"})
@@ -40,32 +48,7 @@ func startIpc(cfg IpcConfig, codec codec.Codec, api api.EthereumApi) error {
continue
}
- go func(conn net.Conn) {
- codec := codec.New(conn)
-
- for {
- req, err := codec.ReadRequest()
- if err == io.EOF {
- codec.Close()
- return
- } else if err != nil {
- glog.V(logger.Error).Infof("IPC recv err - %v\n", err)
- codec.Close()
- return
- }
-
- var rpcResponse interface{}
- res, err := api.Execute(req)
-
- rpcResponse = shared.NewRpcResponse(req.Id, req.Jsonrpc, res, err)
- err = codec.WriteResponse(rpcResponse)
- if err != nil {
- glog.V(logger.Error).Infof("IPC send err - %v\n", err)
- codec.Close()
- return
- }
- }
- }(conn)
+ go handle(conn, api, codec)
}
os.Remove(cfg.Endpoint)