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

Nio2Session improvements #494

Merged
merged 3 commits into from
May 4, 2024
Merged

Conversation

evgeny-pasynkov
Copy link
Contributor

@evgeny-pasynkov evgeny-pasynkov commented May 2, 2024

The proposed improvements for Nio2Session class are based on production experience and fixing some corner cases.

  • When the buffer fails to be written, mark the corresponding Future as finished exceptionally
  • When underlying network infrastructure splits buffer to multiple write chunks, the second and next chunks were written without respect to configured write timeout
  • Minor consistency improvement: use better data structure for write queues which honours possibly concurrent access

Previously, if any exception occurs during write, the corresponding future was set as successful. This commit fixes behaviour and sets future as completed with exception
ConcurrentLinkedQueue is more suitable here
- it ensures add/poll synchronization. The continuation handler is called from multiple threads, and it is good to have synchronized access
- no specific from previously TransferQueue is used
If the requested buffer was not written in a single chunk and the handleCompletedWriteCycle processes incomplete write, all next writes were called without configured timeout. This commit fixes the behaviour and set timeout for next "socket.write" calls.

Note: The configured timeout is used for each data chunk, meaning that depending on underlying network layer the actual buffer write may take longer than timeout
@tomaswolf
Copy link
Member

Thank you, Evgeny! That looks great!

@tomaswolf tomaswolf merged commit 4b40da3 into apache:master May 4, 2024
8 checks passed
@tomaswolf tomaswolf added this to the 2.13.0 milestone May 4, 2024
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