aboutsummaryrefslogtreecommitdiffstats
path: root/rpc/server.go
diff options
context:
space:
mode:
authorFelix Lange <fjl@twurst.com>2016-07-12 23:42:44 +0800
committerFelix Lange <fjl@twurst.com>2016-07-23 05:21:27 +0800
commitbb01bea4e276dad359815c682a2dee730737f4dc (patch)
tree9d290506199e836275f39668fff7edfde842e794 /rpc/server.go
parentc145589f25445b9fb78e4556b17cde29df5b37bb (diff)
downloaddexon-bb01bea4e276dad359815c682a2dee730737f4dc.tar.gz
dexon-bb01bea4e276dad359815c682a2dee730737f4dc.tar.zst
dexon-bb01bea4e276dad359815c682a2dee730737f4dc.zip
rpc: fix bad method error for batch requests
If a batch request contained an invalid method, the server would reply with a non-batch error response. Fix this by tracking an error for each batch element.
Diffstat (limited to 'rpc/server.go')
-rw-r--r--rpc/server.go7
1 files changed, 6 insertions, 1 deletions
diff --git a/rpc/server.go b/rpc/server.go
index 80976ed62..a9bdef285 100644
--- a/rpc/server.go
+++ b/rpc/server.go
@@ -180,7 +180,7 @@ func (s *Server) serveRequest(codec ServerCodec, singleShot bool, options CodecO
for atomic.LoadInt32(&s.run) == 1 {
reqs, batch, err := s.readRequest(codec)
if err != nil {
- glog.V(logger.Debug).Infof("%v\n", err)
+ glog.V(logger.Debug).Infof("read error %v\n", err)
codec.Write(codec.CreateErrorResponse(nil, err))
return nil
}
@@ -394,6 +394,11 @@ func (s *Server) readRequest(codec ServerCodec) ([]*serverRequest, bool, RPCErro
var ok bool
var svc *service
+ if r.err != nil {
+ requests[i] = &serverRequest{id: r.id, err: r.err}
+ continue
+ }
+
if r.isPubSub && r.method == unsubscribeMethod {
requests[i] = &serverRequest{id: r.id, isUnsubscribe: true}
argTypes := []reflect.Type{reflect.TypeOf("")} // expect subscription id as first arg