Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve socket close behavior #1155

Merged
merged 5 commits into from
Jun 6, 2024
Merged

Improve socket close behavior #1155

merged 5 commits into from
Jun 6, 2024

Conversation

scottf
Copy link
Contributor

@scottf scottf commented May 31, 2024

Force Reconnect improvement

Execute forceClose with an executor task inside forceReconnect. This prevents the force reconnect behavior from being blocked if close blocks.


SocketDataPortWithWriteTimeout tuning

In the SocketDataPortWithWriteTimeout implementation of the timeout watcher task:

  1. Call the forceReconnect directly instead of running it on an executor task thread. It's already running on an executor task thread because that's where the watcher runs.
  2. Removed the call to close the output stream of the socket. It's going to get closed anyway when the socket gets closed.

Socket SO LINGER

Added an Options.socketSoLinger(int socketSoLinger) for the user to set the underlying socket.setSoLinger(). This will be used in normal close operations. If a forceClose is requested, any option value supplied will be overridden with setSoLinger(true, 0)


Force Close

Added a forceClose() to the DataPort interface (with a default implementation that calls close(), to ensure interface backward compatibility)

  1. the base internal implementation, SocketDataPort implements forceClose()
  2. forceReconnect calls forceClose()
  3. handleCommunicationIssue calls forceClose

@scottf scottf changed the title Trying to ensure no blocking close on force reconnect Improve socket close behavior Jun 5, 2024
@aricart aricart self-requested a review June 6, 2024 14:53
Copy link
Member

@aricart aricart left a comment

Choose a reason for hiding this comment

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

LGTM

@scottf scottf merged commit 76fac05 into main Jun 6, 2024
2 checks passed
@scottf scottf deleted the ensure-no-block-close branch June 6, 2024 15:36
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