From 783ca188ab2a892d516d3b8bf20d7eaa0ff3485d Mon Sep 17 00:00:00 2001 From: Vladimir Lavor Date: Thu, 22 Feb 2024 15:53:09 +0100 Subject: [PATCH] Do not use trace lock if trace is disabled Signed-off-by: Vladimir Lavor --- core/request_handler.go | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/core/request_handler.go b/core/request_handler.go index a3b2b2e8..577abf68 100644 --- a/core/request_handler.go +++ b/core/request_handler.go @@ -113,9 +113,9 @@ func (c *Connection) processRequest(ch *Channel, req *vppRequest) error { if err = func() (err error) { timestamp := c.trace.registerNew() err = c.vppClient.SendMsg(context, data) - c.traceLock.Lock() - defer c.traceLock.Unlock() if c.trace != nil { + c.traceLock.Lock() + defer c.traceLock.Unlock() c.trace.send(&api.Record{ Message: req.msg, Timestamp: timestamp, @@ -158,9 +158,9 @@ func (c *Connection) processRequest(ch *Channel, req *vppRequest) error { if err = func() (err error) { timestamp := c.trace.registerNew() err = c.vppClient.SendMsg(context, pingData) - c.traceLock.Lock() - defer c.traceLock.Unlock() if c.trace != nil { + c.traceLock.Lock() + defer c.traceLock.Unlock() c.trace.send(&api.Record{ Message: c.msgControlPing, Timestamp: timestamp, @@ -214,9 +214,9 @@ func (c *Connection) msgCallback(msgID uint16, data []byte) { if err = func() (err error) { timestamp := c.trace.registerNew() err = c.codec.DecodeMsg(data, msg) - c.traceLock.Lock() - defer c.traceLock.Unlock() if c.trace != nil { + c.traceLock.Lock() + defer c.traceLock.Unlock() c.trace.send(&api.Record{ Message: msg, Timestamp: timestamp,