bugfix with pub sub name collision with RPC method

This commit is contained in:
Bas van Kervel 2015-11-24 10:21:53 +01:00
parent 417d6acb6e
commit 80fda3e8ac
3 changed files with 21 additions and 20 deletions

View file

@ -130,7 +130,7 @@ func (s *Server) ServeCodec(codec ServerCodec) {
const size = 64 << 10
buf := make([]byte, size)
buf = buf[:runtime.Stack(buf, false)]
glog.Errorln(buf)
glog.Errorln(string(buf))
}
codec.Close()
}()
@ -437,6 +437,7 @@ func (s *Server) readRequest(codec ServerCodec) ([]*serverRequest, bool, RPCErro
continue
}
if r.isPubSub { // eth_subscribe
if callb, ok := svc.subscriptions[r.method]; ok {
requests[i] = &serverRequest{id: r.id, svcname: svc.name, callb: callb}
if r.params != nil && len(callb.argTypes) > 0 {
@ -448,6 +449,9 @@ func (s *Server) readRequest(codec ServerCodec) ([]*serverRequest, bool, RPCErro
requests[i].err = &invalidParamsError{err.Error()}
}
}
} else {
requests[i].err = &methodNotFoundError{subscribeMethod, r.method}
}
continue
}

View file

@ -125,13 +125,13 @@ METHODS:
continue
}
if isPubSub(mtype) {
var h callback
h.isSubscribe = isPubSub(mtype)
h.rcvr = rcvr
h.method = method
h.errPos = -1
h.isSubscribe = true
if h.isSubscribe {
h.argTypes = make([]reflect.Type, mtype.NumIn()-1) // skip rcvr type
for i := 1; i < mtype.NumIn(); i++ {
argType := mtype.In(i)
@ -146,9 +146,6 @@ METHODS:
continue METHODS
}
var h callback
h.rcvr = rcvr
h.method = method
numIn := mtype.NumIn()
// determine method arguments, ignore first arg since it's the receiver type