Skip to content

Commit

Permalink
Do not use trace lock if trace is disabled
Browse files Browse the repository at this point in the history
Signed-off-by: Vladimir Lavor <vlavor@cisco.com>
  • Loading branch information
VladoLavor committed Feb 22, 2024
1 parent e33b77a commit 783ca18
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions core/request_handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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,
Expand Down

0 comments on commit 783ca18

Please sign in to comment.