aboutsummaryrefslogtreecommitdiffstats
path: root/rpc/comms/ipc_unix.go
diff options
context:
space:
mode:
authorBas van Kervel <bas@ethdev.com>2015-06-16 17:16:50 +0800
committerBas van Kervel <bas@ethdev.com>2015-06-22 14:54:21 +0800
commit60c2ccd99cd9acdb628a9ba5e16ad0e7e52b7e17 (patch)
tree24ab79f06b1d51b8c0967e6e5f6bedd46ebc710d /rpc/comms/ipc_unix.go
parent9cf7913c61c6f9c1f36a44778a75e6a91a741be4 (diff)
downloaddexon-60c2ccd99cd9acdb628a9ba5e16ad0e7e52b7e17.tar
dexon-60c2ccd99cd9acdb628a9ba5e16ad0e7e52b7e17.tar.gz
dexon-60c2ccd99cd9acdb628a9ba5e16ad0e7e52b7e17.tar.bz2
dexon-60c2ccd99cd9acdb628a9ba5e16ad0e7e52b7e17.tar.lz
dexon-60c2ccd99cd9acdb628a9ba5e16ad0e7e52b7e17.tar.xz
dexon-60c2ccd99cd9acdb628a9ba5e16ad0e7e52b7e17.tar.zst
dexon-60c2ccd99cd9acdb628a9ba5e16ad0e7e52b7e17.zip
made ipc handler generic and reusable
Diffstat (limited to 'rpc/comms/ipc_unix.go')
-rw-r--r--rpc/comms/ipc_unix.go29
1 files changed, 1 insertions, 28 deletions
diff --git a/rpc/comms/ipc_unix.go b/rpc/comms/ipc_unix.go
index 5a94fd1e0..131fb86f2 100644
--- a/rpc/comms/ipc_unix.go
+++ b/rpc/comms/ipc_unix.go
@@ -3,7 +3,6 @@
package comms
import (
- "io"
"net"
"os"
@@ -11,7 +10,6 @@ import (
"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"
)
func newIpcClient(cfg IpcConfig, codec codec.Codec) (*ipcClient, error) {
@@ -40,32 +38,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)