From 6dd658f579ae4e1d9704e14380b69fe906c57ad2 Mon Sep 17 00:00:00 2001 From: Ondrej Fabry Date: Fri, 8 Mar 2019 11:18:22 +0100 Subject: Add socketclient implementation Change-Id: Ibf9edc0e5911d08229ac590b37c5afbc27f424a0 Signed-off-by: Ondrej Fabry --- core/channel.go | 5 +++-- core/request_handler.go | 8 +++++--- 2 files changed, 8 insertions(+), 5 deletions(-) (limited to 'core') diff --git a/core/channel.go b/core/channel.go index bf27b73..6cb02f7 100644 --- a/core/channel.go +++ b/core/channel.go @@ -258,6 +258,7 @@ func (ch *Channel) receiveReplyInternal(msg api.Message, expSeqNum uint16) (last case vppReply := <-ch.replyChan: ignore, lastReplyReceived, err = ch.processReply(vppReply, expSeqNum, msg) if ignore { + logrus.Warnf("ignoring reply: %+v", vppReply) continue } return lastReplyReceived, err @@ -275,8 +276,8 @@ 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 - logrus.WithField("seqNum", reply.seqNum).Warn( - "Received reply to an already closed binary API request") + logrus.WithField("seqNum", reply.seqNum). + Warn("Received reply to an already closed binary API request") ignore = true return } diff --git a/core/request_handler.go b/core/request_handler.go index 55a825a..fd8aa59 100644 --- a/core/request_handler.go +++ b/core/request_handler.go @@ -23,6 +23,8 @@ import ( logger "github.com/sirupsen/logrus" ) +var ReplyChannelTimeout = time.Millisecond * 100 + var ( ErrNotConnected = errors.New("not connected to VPP, ignoring the request") ErrProbeTimeout = errors.New("probe reply not received within timeout period") @@ -91,7 +93,7 @@ func (c *Connection) processRequest(ch *Channel, req *vppRequest) error { "msg_size": len(data), "seq_num": req.seqNum, "msg_crc": req.msg.GetCrcString(), - }).Debugf(" --> sending msg: %s", req.msg.GetMessageName()) + }).Debugf("--> govpp send: %s: %+v", req.msg.GetMessageName(), req.msg) } // send the request to VPP @@ -163,7 +165,7 @@ func (c *Connection) msgCallback(msgID uint16, data []byte) { "is_multi": isMulti, "seq_num": seqNum, "msg_crc": msg.GetCrcString(), - }).Debugf(" <- received msg: %s", msg.GetMessageName()) + }).Debugf("<-- govpp recv: %s", msg.GetMessageName()) } if context == 0 || c.isNotificationMessage(msgID) { @@ -209,7 +211,7 @@ func sendReply(ch *Channel, reply *vppReply) { select { case ch.replyChan <- reply: // reply sent successfully - case <-time.After(time.Millisecond * 100): + case <-time.After(ReplyChannelTimeout): // receiver still not ready log.WithFields(logger.Fields{ "channel": ch, -- cgit 1.2.3-korg