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

StreamSocket::checkRemoval: Signal shutdown only if appropriate #10326

Closed

Conversation

sgothel
Copy link

@sgothel sgothel commented Oct 25, 2024

Change-Id: I4e3ba962880b77017443236bc33b03ed20dcdd34

Summary

Signal shutdown only if appropriate, allowing to drain bytes instead of hard disconnect. Only in case of SigUtil::getTerminationFlag(), we force disconnection.

SocketPoll::poll() hence checks isClosed() after checkRemoval() for forced Socket removal. A pending signaled shutdown may occure via handlePoll() after processing more I/O data.

Further, remove useless setClosed() in checkRemoval() after asserting !isOpen().

Checklist

  • I have run make prettier-write and formatted the code.
  • All commits have Change-Id
  • I have run tests with make check
  • I have issued make run and manually verified that everything looks okay
  • Documentation (manuals or wiki) has been updated or is not required

net/Socket.cpp Outdated Show resolved Hide resolved
…wing to drain bytes instead of hard disconnect

Signal shutdown only if appropriate, allowing to drain bytes instead of hard disconnect.
Only in case of SigUtil::getTerminationFlag(), we force disconnection.

SocketPoll::poll() hence checks isClosed() after checkRemoval() for forced Socket removal.
A pending signaled shutdown may occure via handlePoll() after processing more I/O data.

Further, remove useless setClosed() in checkRemoval() after asserting !isOpen().

Signed-off-by: Sven Göthel <[email protected]>
Change-Id: I4e3ba962880b77017443236bc33b03ed20dcdd34
@sgothel sgothel force-pushed the private/sgothel/socket_removal_signalshutdown_only branch from f81ec5c to 46aab7f Compare October 25, 2024 12:53
shutdown(); // signal
closeConnection(); // real -> setClosed()
_socketHandler->onDisconnect(); // Note: Ensure proper semantics of onDisconnect()
if( isOpen() )
Copy link
Contributor

Choose a reason for hiding this comment

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

Spacing could also benefit from fixing up: if (isOpen()).

The reason this is more readable (I think) is because language statements are (emphatically) not function calls. Making them stand out helps the eye scan faster and more accurately. I suspect the preference to make them look like function calls is to homogenize the code, but in this case it can be misleading to the reader. Ditto for while, for, do, return, etc.

@sgothel sgothel closed this Nov 1, 2024
@sgothel sgothel deleted the private/sgothel/socket_removal_signalshutdown_only branch November 1, 2024 11:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
Archived in project
Development

Successfully merging this pull request may close these issues.

Handle limited open Connections due to keepalive connections (cool#9621)
3 participants