Code Review
/
govpp.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
review
|
tree
raw
|
inline
| side by side
Improve compatibility checking
[govpp.git]
/
core
/
channel.go
diff --git
a/core/channel.go
b/core/channel.go
index
6cb02f7
..
363a267
100644
(file)
--- a/
core/channel.go
+++ b/
core/channel.go
@@
-21,8
+21,10
@@
import (
"strings"
"time"
"strings"
"time"
- "git.fd.io/govpp.git/api"
"github.com/sirupsen/logrus"
"github.com/sirupsen/logrus"
+
+ "git.fd.io/govpp.git/adapter"
+ "git.fd.io/govpp.git/api"
)
var (
)
var (
@@
-143,13
+145,23
@@
func (ch *Channel) SendMultiRequest(msg api.Message) api.MultiRequestCtx {
}
func (ch *Channel) CheckCompatiblity(msgs ...api.Message) error {
}
func (ch *Channel) CheckCompatiblity(msgs ...api.Message) error {
+ var comperr api.CompatibilityError
for _, msg := range msgs {
_, err := ch.msgIdentifier.GetMessageID(msg)
if err != nil {
for _, msg := range msgs {
_, err := ch.msgIdentifier.GetMessageID(msg)
if err != nil {
+ if uerr, ok := err.(*adapter.UnknownMsgError); ok {
+ m := fmt.Sprintf("%s_%s", uerr.MsgName, uerr.MsgCrc)
+ comperr.IncompatibleMessages = append(comperr.IncompatibleMessages, m)
+ continue
+ }
+ // other errors return immediatelly
return err
}
}
return err
}
}
- return nil
+ if len(comperr.IncompatibleMessages) == 0 {
+ return nil
+ }
+ return &comperr
}
func (ch *Channel) SubscribeNotification(notifChan chan api.Message, event api.Message) (api.SubscriptionCtx, error) {
}
func (ch *Channel) SubscribeNotification(notifChan chan api.Message, event api.Message) (api.SubscriptionCtx, error) {
@@
-184,10
+196,7
@@
func (ch *Channel) SetReplyTimeout(timeout time.Duration) {
}
func (ch *Channel) Close() {
}
func (ch *Channel) Close() {
- if ch.reqChan != nil {
- close(ch.reqChan)
- ch.reqChan = nil
- }
+ close(ch.reqChan)
}
func (req *requestCtx) ReceiveReply(msg api.Message) error {
}
func (req *requestCtx) ReceiveReply(msg api.Message) error {
@@
-258,17
+267,23
@@
func (ch *Channel) receiveReplyInternal(msg api.Message, expSeqNum uint16) (last
case vppReply := <-ch.replyChan:
ignore, lastReplyReceived, err = ch.processReply(vppReply, expSeqNum, msg)
if ignore {
case vppReply := <-ch.replyChan:
ignore, lastReplyReceived, err = ch.processReply(vppReply, expSeqNum, msg)
if ignore {
- logrus.Warnf("ignoring reply: %+v", vppReply)
+ log.WithFields(logrus.Fields{
+ "expSeqNum": expSeqNum,
+ "channel": ch.id,
+ }).Warnf("ignoring received reply: %+v (expecting: %s)", vppReply, msg.GetMessageName())
continue
}
return lastReplyReceived, err
case <-timer.C:
continue
}
return lastReplyReceived, err
case <-timer.C:
+ log.WithFields(logrus.Fields{
+ "expSeqNum": expSeqNum,
+ "channel": ch.id,
+ }).Debugf("timeout (%v) waiting for reply: %s", ch.replyTimeout, msg.GetMessageName())
err = fmt.Errorf("no reply received within the timeout period %s", ch.replyTimeout)
return false, err
}
}
err = fmt.Errorf("no reply received within the timeout period %s", ch.replyTimeout)
return false, err
}
}
- return
}
func (ch *Channel) processReply(reply *vppReply, expSeqNum uint16, msg api.Message) (ignore bool, lastReplyReceived bool, err error) {
}
func (ch *Channel) processReply(reply *vppReply, expSeqNum uint16, msg api.Message) (ignore bool, lastReplyReceived bool, err error) {
@@
-276,7
+291,7
@@
func (ch *Channel) processReply(reply *vppReply, expSeqNum uint16, msg api.Messa
cmpSeqNums := compareSeqNumbers(reply.seqNum, expSeqNum)
if cmpSeqNums == -1 {
// reply received too late, ignore the message
cmpSeqNums := compareSeqNumbers(reply.seqNum, expSeqNum)
if cmpSeqNums == -1 {
// reply received too late, ignore the message
- log
rus
.WithField("seqNum", reply.seqNum).
+ log.WithField("seqNum", reply.seqNum).
Warn("Received reply to an already closed binary API request")
ignore = true
return
Warn("Received reply to an already closed binary API request")
ignore = true
return