diff options
author | Dave Barach <dave@barachs.net> | 2020-07-10 12:19:01 -0400 |
---|---|---|
committer | Dave Barach <dave@barachs.net> | 2020-07-14 10:25:48 -0400 |
commit | 1548c7e12531e3d055567d761c580a1c7ff0ac40 (patch) | |
tree | a6a6d01ae6aa6e10c1420fd47a80bd29f989d729 /adapter/socketclient/socketclient.go | |
parent | f4f4a8613711d724cd4dc7224e8d7a1de4b8050e (diff) |
socket adapter: don't bother sending sockclnt_delete messages
vpp cleans up socket clients when the socket closes. I verified that
sending a correctly-marshalled sockclnt_delete message results in
duplicate close complaints.
The marshalling code wasn't right - the (important) client_index field
is in a non-standard position - and there's no point in sending
a message we don't need to send.
Signed-off-by: Dave Barach <dave@barachs.net>
Change-Id: Ia32980b08a99cc878835f5db21f64de391759fa4
Diffstat (limited to 'adapter/socketclient/socketclient.go')
-rw-r--r-- | adapter/socketclient/socketclient.go | 47 |
1 files changed, 2 insertions, 45 deletions
diff --git a/adapter/socketclient/socketclient.go b/adapter/socketclient/socketclient.go index b2c5d47..f63e8b8 100644 --- a/adapter/socketclient/socketclient.go +++ b/adapter/socketclient/socketclient.go @@ -266,9 +266,8 @@ func (c *socketClient) Disconnect() error { // wait for readerLoop to return c.wg.Wait() - if err := c.close(); err != nil { - log.Debugf("closing failed: %v", err) - } + // Don't bother sending a vl_api_sockclnt_delete_t message, + // just close the socket. if err := c.disconnect(); err != nil { return err @@ -375,48 +374,6 @@ func (c *socketClient) open() error { return nil } -func (c *socketClient) close() error { - var msgCodec = codec.DefaultCodec - - req := &memclnt.SockclntDelete{ - Index: c.clientIndex, - } - msg, err := msgCodec.EncodeMsg(req, c.sockDelMsgId) - if err != nil { - log.Debugln("Encode error:", err) - return err - } - // set non-0 context - msg[5] = deleteMsgContext - - log.Debugf("sending socklntDel (%d bytes): % 0X", len(msg), msg) - - if err := c.writeMsg(msg); err != nil { - log.Debugln("Write error: ", err) - return err - } - - msgReply, err := c.readMsgTimeout(nil, c.disconnectTimeout) - if err != nil { - if nerr, ok := err.(net.Error); ok && nerr.Timeout() { - // we accept timeout for reply - return nil - } - log.Debugln("Read error:", err) - return err - } - - reply := new(memclnt.SockclntDeleteReply) - if err := msgCodec.DecodeMsg(msgReply, reply); err != nil { - log.Debugln("Decoding sockclnt_delete_reply failed:", err) - return err - } else if reply.Response != 0 { - return fmt.Errorf("sockclnt_delete_reply: response error (%d)", reply.Response) - } - - return nil -} - func (c *socketClient) GetMsgID(msgName string, msgCrc string) (uint16, error) { if msgID, ok := c.msgTable[msgName+"_"+msgCrc]; ok { return msgID, nil |