From 73f7004c74194532f49aecd7a8b64e58823bed08 Mon Sep 17 00:00:00 2001 From: Todd Date: Thu, 20 Oct 2022 14:02:38 -0700 Subject: [PATCH] Add RLocks for all read access to s.connInfoMaps in a session (#2553) * Add RLocks for all read access to s.connInfoMaps in a session --- CHANGELOG.md | 2 ++ internal/daemon/worker/session/session.go | 4 ++++ 2 files changed, 6 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 6115fb0fc..4547c357e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -16,6 +16,8 @@ Canonical reference for changes, improvements, and bugfixes for Boundary. could be written to stdout along with a message that they could not successfully be evented instead of being written to the event log ([PR](https://github.com/hashicorp/boundary/pull/2544)) +* workers: Fixed a panic that can happen in certain situations + ([PR](https://github.com/hashicorp/boundary/pull/2553)) ## 0.11.0 (2022/09/27) diff --git a/internal/daemon/worker/session/session.go b/internal/daemon/worker/session/session.go index 1f8e34042..7562f7b4a 100644 --- a/internal/daemon/worker/session/session.go +++ b/internal/daemon/worker/session/session.go @@ -313,6 +313,8 @@ func (s *sess) RequestConnectConnection(ctx context.Context, info *pbs.ConnectCo // // The returned slice are connection ids that were closed. func (s *sess) CancelOpenLocalConnections() []string { + s.lock.RLock() + defer s.lock.RUnlock() var closedIds []string for k, v := range s.connInfoMap { if v.Status != pbs.CONNECTIONSTATUS_CONNECTIONSTATUS_CLOSED { @@ -336,6 +338,8 @@ func (s *sess) CancelOpenLocalConnections() []string { // // The returned slice is the connection ids which were closed. func (s *sess) CancelAllLocalConnections() []string { + s.lock.RLock() + defer s.lock.RUnlock() var closedIds []string for k, v := range s.connInfoMap { v.connCtxCancelFunc()