Skip to content

[23655] Solve TCP disconnect while incomplete read deadlock (backport #6066)#6092

Merged
juanlofer-eprosima merged 1 commit into2.14.xfrom
mergify/bp/2.14.x/pr-6066
Oct 13, 2025
Merged

[23655] Solve TCP disconnect while incomplete read deadlock (backport #6066)#6092
juanlofer-eprosima merged 1 commit into2.14.xfrom
mergify/bp/2.14.x/pr-6066

Conversation

@mergify
Copy link
Copy Markdown
Contributor

@mergify mergify Bot commented Oct 9, 2025

Description

This PR attempts to solve the deadlock produced when a read operation never completes (e.g. peer blocks before ending a transmission), and the TCP channel resource is disconnected (normally on closure while cleaning the associated transport).
Summing up, the solution consists in shutting down the socket before acquiring the culprit read mutex, so that any ongoing write/read operations are aborted even if not completed.

In addition, some other changes in this PR target general thread safety and attempt to improve overall resilience:

  • New "disconnecting" state to protect from concurrent connect/disconnects.
  • Assert that socket options are only configured before connection is established.

@Mergifyio backport 3.3.x 3.2.x 2.14.x

Contributor Checklist

  • Commit messages follow the project guidelines.

  • The code follows the style guidelines of this project.

  • Tests that thoroughly check the new feature have been added/Regression tests checking the bug and its fix have been added; the added tests pass locally

  • N/a Any new/modified methods have been properly documented using Doxygen.

  • N/a Any new configuration API has an equivalent XML API (with the corresponding XSD extension)

  • Changes are backport compatible: they do NOT break ABI nor change library core behavior.

  • Changes are API compatible.

  • N/a New feature has been added to the versions.md file (if applicable).

  • N/a New feature has been documented/Current behavior is correctly described in the documentation.

  • Applicable backports have been included in the description.

Reviewer Checklist

  • The PR has a milestone assigned.
  • The title and description correctly express the PR's purpose.
  • Check contributor checklist is correct.
  • N/a If this is a critical bug fix, backports to the critical-only supported branches have been requested.
  • Check CI results: changes do not issue any warning.
  • Check CI results: failing tests are unrelated with the changes.

This is an automatic backport of pull request #6066 done by [Mergify](https://mergify.com).

@mergify mergify Bot added the conflicts Backport PR wich git cherry pick failed label Oct 9, 2025
@mergify
Copy link
Copy Markdown
Contributor Author

mergify Bot commented Oct 9, 2025

Cherry-pick of f2e173c has failed:

On branch mergify/bp/2.14.x/pr-6066
Your branch is up to date with 'origin/2.14.x'.

You are currently cherry-picking commit f2e173c7.
  (fix conflicts and run "git cherry-pick --continue")
  (use "git cherry-pick --skip" to skip this patch)
  (use "git cherry-pick --abort" to cancel the cherry-pick operation)

Changes to be committed:
	modified:   src/cpp/fastdds/core/condition/StatusConditionImpl.cpp
	modified:   src/cpp/fastdds/core/condition/StatusConditionImpl.hpp
	modified:   src/cpp/rtps/transport/TCPAcceptorSecure.cpp
	modified:   src/cpp/rtps/transport/TCPChannelResource.cpp
	modified:   src/cpp/rtps/transport/TCPChannelResource.h
	modified:   src/cpp/rtps/transport/TCPChannelResourceBasic.cpp
	modified:   src/cpp/rtps/transport/TCPChannelResourceBasic.h
	modified:   src/cpp/rtps/transport/TCPChannelResourceSecure.cpp
	modified:   src/cpp/rtps/transport/TCPTransportInterface.cpp
	modified:   test/unittest/transport/TCPv4Tests.cpp
	modified:   test/unittest/transport/TCPv6Tests.cpp

Unmerged paths:
  (use "git add <file>..." to mark resolution)
	both modified:   test/blackbox/common/BlackboxTestsTransportTCP.cpp

To fix up this pull request, you can check it out locally. See documentation: https://docs.github.com/en/pull-requests/collaborating-with-pull-requests/reviewing-changes-in-pull-requests/checking-out-pull-requests-locally

* Refs #23655. Add regression test

Signed-off-by: Juan Lopez Fernandez <juanlopez@eprosima.com>

* Refs #23655. Solve deadlock and improve thread safety

Signed-off-by: Juan Lopez Fernandez <juanlopez@eprosima.com>

* Refs #23655. Bonus track: protect status getter

Signed-off-by: Juan Lopez Fernandez <juanlopez@eprosima.com>

* Refs #23655. Fix test in Windows

Signed-off-by: Juan Lopez Fernandez <juanlopez@eprosima.com>

* Refs #23655. Remove deprecated code

Signed-off-by: Juan Lopez Fernandez <juanlopez@eprosima.com>

* Refs #23655. Restore noexcept overloads usage

Signed-off-by: Juan Lopez Fernandez <juanlopez@eprosima.com>

* Refs #23655. Apply suggestions

Signed-off-by: Juan Lopez Fernandez <juanlopez@eprosima.com>

---------

Signed-off-by: Juan Lopez Fernandez <juanlopez@eprosima.com>
(cherry picked from commit f2e173c)

# Conflicts:
#	test/blackbox/common/BlackboxTestsTransportTCP.cpp
@juanlofer-eprosima juanlofer-eprosima force-pushed the mergify/bp/2.14.x/pr-6066 branch from 674e1c7 to 34c83e7 Compare October 10, 2025 12:20
@juanlofer-eprosima juanlofer-eprosima removed the conflicts Backport PR wich git cherry pick failed label Oct 10, 2025
@juanlofer-eprosima juanlofer-eprosima requested review from richiprosima and removed request for richiprosima October 10, 2025 12:21
@github-actions github-actions Bot added the ci-pending PR which CI is running label Oct 10, 2025
@mergify
Copy link
Copy Markdown
Contributor Author

mergify Bot commented Oct 10, 2025

🧪 CI Insights

Here's what we observed from your CI run for 34c83e7.

❌ Job Failures

Pipeline Job Health on 2.14.x Retries 🔍 CI Insights 📄 Logs
Fast-DDS MacOS CI mac-ci / reusable-mac-ci (RelWithDebInfo) Unknown 0 View View

Copy link
Copy Markdown
Contributor

@juanlofer-eprosima juanlofer-eprosima left a comment

Choose a reason for hiding this comment

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

LGTM

@juanlofer-eprosima juanlofer-eprosima merged commit 1139fa6 into 2.14.x Oct 13, 2025
18 of 19 checks passed
@juanlofer-eprosima juanlofer-eprosima deleted the mergify/bp/2.14.x/pr-6066 branch October 13, 2025 05:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ci-pending PR which CI is running

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant