aboutsummaryrefslogtreecommitdiffstats
path: root/rpc/comms/comms.go
diff options
context:
space:
mode:
authorBas van Kervel <bas@ethdev.com>2015-10-29 15:40:07 +0800
committerBas van Kervel <bas@ethdev.com>2015-10-29 16:23:03 +0800
commitc3c5f8b654f9ddaeedeb2d3d5d1caf000e08320e (patch)
tree37a575308d81a95cc22c667841f82a7c4b083fd8 /rpc/comms/comms.go
parent56f8699a6c6bfe613d2ab28c47631a1f4a29e36f (diff)
downloaddexon-c3c5f8b654f9ddaeedeb2d3d5d1caf000e08320e.tar
dexon-c3c5f8b654f9ddaeedeb2d3d5d1caf000e08320e.tar.gz
dexon-c3c5f8b654f9ddaeedeb2d3d5d1caf000e08320e.tar.bz2
dexon-c3c5f8b654f9ddaeedeb2d3d5d1caf000e08320e.tar.lz
dexon-c3c5f8b654f9ddaeedeb2d3d5d1caf000e08320e.tar.xz
dexon-c3c5f8b654f9ddaeedeb2d3d5d1caf000e08320e.tar.zst
dexon-c3c5f8b654f9ddaeedeb2d3d5d1caf000e08320e.zip
rpc: fixed params parsing problem which could lead to a panic
check argument type before parsing params recover from panic in ipc channel
Diffstat (limited to 'rpc/comms/comms.go')
-rw-r--r--rpc/comms/comms.go11
1 files changed, 7 insertions, 4 deletions
diff --git a/rpc/comms/comms.go b/rpc/comms/comms.go
index 731b2f62e..61fba5722 100644
--- a/rpc/comms/comms.go
+++ b/rpc/comms/comms.go
@@ -62,13 +62,18 @@ type EthereumClient interface {
func handle(id int, conn net.Conn, api shared.EthereumApi, c codec.Codec) {
codec := c.New(conn)
+ defer func() {
+ if r := recover(); r != nil {
+ glog.Errorf("panic: %v\n", r)
+ }
+ codec.Close()
+ }()
+
for {
requests, isBatch, err := codec.ReadRequest()
if err == io.EOF {
- codec.Close()
return
} else if err != nil {
- codec.Close()
glog.V(logger.Debug).Infof("Closed IPC Conn %06d recv err - %v\n", id, err)
return
}
@@ -87,7 +92,6 @@ func handle(id int, conn net.Conn, api shared.EthereumApi, c codec.Codec) {
err = codec.WriteResponse(responses[:responseCount])
if err != nil {
- codec.Close()
glog.V(logger.Debug).Infof("Closed IPC Conn %06d send err - %v\n", id, err)
return
}
@@ -98,7 +102,6 @@ func handle(id int, conn net.Conn, api shared.EthereumApi, c codec.Codec) {
rpcResponse = shared.NewRpcResponse(requests[0].Id, requests[0].Jsonrpc, res, err)
err = codec.WriteResponse(rpcResponse)
if err != nil {
- codec.Close()
glog.V(logger.Debug).Infof("Closed IPC Conn %06d send err - %v\n", id, err)
return
}