Skip to content

ssl: Stop the sender socket side if error - #10011

Merged
dgud merged 2 commits into
erlang:maintfrom
dgud:dgud/ssl/close-sender/OTP-19694
Jul 5, 2025
Merged

dgud merged 2 commits into
erlang:maintfrom
dgud:dgud/ssl/close-sender/OTP-19694

Conversation

@dgud

@dgud dgud commented Jul 1, 2025

Copy link
Copy Markdown
Contributor

When socket reports an error close down the socket sender process to avoid trying to send something else.

When socket reports an error close down the socket sender process
to avoid trying to send something else.
@dgud
dgud requested a review from IngelaAndin July 1, 2025 14:56
@dgud dgud self-assigned this Jul 1, 2025
@dgud dgud added the team:PS Assigned to OTP team PS label Jul 1, 2025
@github-actions

github-actions Bot commented Jul 1, 2025 •

Copy link
Copy Markdown
Contributor

CT Test Results

    2 files     66 suites   26m 18s ⏱️
  816 tests   773 ✅  43 💤 0 ❌
4 186 runs  3 386 ✅ 800 💤 0 ❌

Results for commit e4a66c1.

♻️ This comment has been updated with latest results.

To speed up review, make sure that you have read Contributing to Erlang/OTP and that all checks pass.

See the TESTING and DEVELOPMENT HowTo guides for details about how to run test locally.

Artifacts

// Erlang/OTP Github Action Bot

@dgud
dgud force-pushed the dgud/ssl/close-sender/OTP-19694 branch from b91746e to de506f6 Compare July 3, 2025 14:33
@dgud dgud added the testing currently being tested, tag is used by OTP internal CI label Jul 3, 2025
IngelaAndin
IngelaAndin previously approved these changes Jul 4, 2025
@dgud
dgud force-pushed the dgud/ssl/close-sender/OTP-19694 branch from de506f6 to b2a2e8b Compare July 4, 2025 08:48
@dgud
dgud requested a review from Copilot July 4, 2025 09:02

This comment was marked as outdated.

Socket needs to bind address before connection, make sure to
bind to the correct outgoing address.
@dgud
dgud force-pushed the dgud/ssl/close-sender/OTP-19694 branch from b2a2e8b to e4a66c1 Compare July 4, 2025 09:08
@dgud
dgud requested a review from Copilot July 4, 2025 09:12

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Pull Request Overview

This PR ensures that when a socket error occurs, the sender process shuts down, and it also adds the ability to bind an explicit outbound port for TCP/TLS connections.

  • Extracts and applies a user-specified port option via get_port/1 in tls_socket_tcp.
  • Updates tls_sender state machine to always invoke death_row_shutdown on errors.
  • Adds outbound port binding in inet_epmd_tls_socket before connecting.

Reviewed Changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 2 comments.

File Description
lib/ssl/src/tls_socket_tcp.erl Added get_port/1 to capture outbound port and passed a BindAddr map through connect_1.
lib/ssl/src/tls_sender.erl Unified error handling to always call death_row_shutdown and removed special-case branches.
lib/ssl/src/inet_epmd_tls_socket.erl Introduced BindAddress construction and bound the socket to it before connect.
Comments suppressed due to low confidence (4)

lib/ssl/src/tls_socket_tcp.erl:320

  • Consider adding a brief @SPEC and doc comment for get_port/1 to explain the returned tuple {OutPort, Opts} and how the port option is consumed.
get_port(Opts0) ->

lib/ssl/src/tls_sender.erl:573

  • The new unified error clause always triggers death_row_shutdown; add or update comments to clarify that non-distribution errors also intentionally shut down the sender.
                {error, _} = Error ->

lib/ssl/src/tls_sender.erl:573

  • There are no new tests covering the unified shutdown behavior on errors; please add unit/integration tests to verify that the sender process stops as expected for both distribution and non-distribution errors.
                {error, _} = Error ->

lib/ssl/src/tls_sender.erl:741

  • The send_post_handshake_data/… case now only handles ok and {error, Reason}; verify that no other return shapes can occur to prevent an unhandled clause runtime crash.
        {error, Reason} ->

Comment thread lib/ssl/src/inet_epmd_tls_socket.erl
@erlang erlang deleted a comment from Copilot AI Jul 4, 2025
@dgud
dgud requested a review from u3s July 4, 2025 12:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

team:PS Assigned to OTP team PS testing currently being tested, tag is used by OTP internal CI

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants