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.
This commit is contained in:
@ -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
|
||||
|
Reference in New Issue
Block a user