Skip to content

Commit

Permalink
RSDK-5440 fix deadlock on simultaneous connect and update (viamroboti…
Browse files Browse the repository at this point in the history
  • Loading branch information
maximpertsov authored Oct 27, 2023
1 parent a9a8c8a commit 0f4c3b0
Showing 1 changed file with 11 additions and 3 deletions.
14 changes: 11 additions & 3 deletions robot/client/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -370,6 +370,17 @@ func (rc *RobotClient) Changed() <-chan bool {
}

func (rc *RobotClient) connect(ctx context.Context) error {
if err := rc.connectWithLock(ctx); err != nil {
return err
}

if rc.notifyParent != nil {
rc.notifyParent()
}
return nil
}

func (rc *RobotClient) connectWithLock(ctx context.Context) error {
rc.mu.Lock()
defer rc.mu.Unlock()

Expand Down Expand Up @@ -398,9 +409,6 @@ func (rc *RobotClient) connect(ctx context.Context) error {
if rc.changeChan != nil {
rc.changeChan <- true
}
if rc.notifyParent != nil {
rc.notifyParent()
}
return nil
}

Expand Down

0 comments on commit 0f4c3b0

Please sign in to comment.