Skip to content

Fix race condition with concurrent teardown of ServiceCtx and re-connection of the preloaded Session Server.#512

Open
smudri85 wants to merge 3 commits into
masterfrom
feature/RDKEMW-19123
Open

Fix race condition with concurrent teardown of ServiceCtx and re-connection of the preloaded Session Server.#512
smudri85 wants to merge 3 commits into
masterfrom
feature/RDKEMW-19123

Conversation

@smudri85
Copy link
Copy Markdown
Contributor

Summary: Fix race condition with concurrent teardown of ServiceCtx and re-connection of the preloaded Session Server
Type: Fix
Test Plan: UT/CT, Fullstack
Jira: RDKEMW-19123

Copilot AI review requested due to automatic review settings May 27, 2026 13:28
@github-actions
Copy link
Copy Markdown

Pull request must be merged with a description containing the required fields,

Summary:
Type: Feature/Fix/Cleanup
Test Plan:
Jira:

If there is no jira releated to this change, please put 'Jira: NO-JIRA'.

Description can be changed by editing the top comment on your pull request and making a new commit.

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Fixes a teardown-time race where ServiceContext can be destroyed while IPC callbacks trigger session-server recovery/reconnect logic, by introducing an explicit “shutting down” signal on ISessionServerAppManager and using it to gate restart/preload behavior.

Changes:

  • Add ISessionServerAppManager::setShuttingDown() and implement it in SessionServerAppManager using an atomic flag.
  • Mark the app manager as shutting down from ServiceContext’s destructor to prevent restart/reconnect during teardown.
  • Add/extend unit tests around “skip restart when shutting down” and a destructor smoke test.

Reviewed changes

Copilot reviewed 10 out of 10 changed files in this pull request and generated 4 comments.

Show a summary per file
File Description
tests/unittests/serverManager/unittests/service/ServerManagerServiceTests.cpp Adds a ServiceContext destructor smoke test and includes ServiceContext.
tests/unittests/serverManager/unittests/common/SessionServerAppManagerTestsFixture.h Adds a trigger helper for the new shutdown flag.
tests/unittests/serverManager/unittests/common/SessionServerAppManagerTestsFixture.cpp Implements the shutdown-flag trigger helper.
tests/unittests/serverManager/unittests/common/SessionServerAppManagerTests.cpp Adds a test intended to verify restart is skipped during shutdown.
tests/unittests/serverManager/mocks/SessionServerAppManagerMock.h Updates the mock interface to include setShuttingDown().
serverManager/service/source/ServiceContext.cpp Calls setShuttingDown() in ServiceContext destructor.
serverManager/service/include/ServiceContext.h Changes destructor declaration; header is now directly included by new tests.
serverManager/common/source/SessionServerAppManager.h Adds setShuttingDown() and switches shutdown flag to std::atomic_bool.
serverManager/common/source/SessionServerAppManager.cpp Implements setShuttingDown() and uses shutdown flag to skip restart/preload; modifies shutdown path.
serverManager/common/include/ISessionServerAppManager.h Extends the interface with setShuttingDown().

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread serverManager/common/source/SessionServerAppManager.cpp
Comment thread tests/unittests/serverManager/unittests/service/ServerManagerServiceTests.cpp Outdated
Comment thread serverManager/service/include/ServiceContext.h
@github-actions
Copy link
Copy Markdown

Coverage statistics of your commit:
Congratulations, your commit improved lines coverage from: 84.2% to 84.4%
Congratulations, your commit improved functions coverage from: 92.6% to 92.9%

@github-actions
Copy link
Copy Markdown

Coverage statistics of your commit:
Congratulations, your commit improved lines coverage from: 84.2% to 84.4%
Congratulations, your commit improved functions coverage from: 92.6% to 92.9%

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants