Skip to content

Non-blocking send#160

Open
zuiderkwast wants to merge 3 commits intoEricsson:single-process-clientfrom
zuiderkwast:non-blocking-send
Open

Non-blocking send#160
zuiderkwast wants to merge 3 commits intoEricsson:single-process-clientfrom
zuiderkwast:non-blocking-send

Conversation

@zuiderkwast
Copy link
Collaborator

Use send_timeout 0. If send returns timeout, it has still queued all the data for sending later. When this happens, backoff and don't send more to the socket until the pending commands have got replies from the server.

Use send_timeout 0. If send returns timeout, it has still queued all the data
for sending later. When this happens, backoff and don't send more to the
socket until the pending commands have got replies from the server.

Signed-off-by: Viktor Söderqvist <viktor.soderqvist@est.tech>
Signed-off-by: Viktor Söderqvist <viktor.soderqvist@est.tech>
@zuiderkwast zuiderkwast marked this pull request as ready for review March 3, 2026 16:11
Signed-off-by: Viktor Söderqvist <viktor.soderqvist@est.tech>
@zuiderkwast
Copy link
Collaborator Author

@zuiderkwast zuiderkwast requested review from bjosv and removed request for JeppeTh, WilliamVoong and drmull March 17, 2026 10:54
Copy link
Collaborator

@bjosv bjosv left a comment

Choose a reason for hiding this comment

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

LGTM, seems to be helpful

Copy link
Collaborator

@WilliamVoong WilliamVoong left a comment

Choose a reason for hiding this comment

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

Hi i think most of it looks good, just have a small comment in ered_client_tests.erl.

Comment on lines +262 to +266
LargeBinary = (fun Loop(0, Acc) ->
Acc;
Loop(I, Acc) ->
Loop(I - 1, <<Acc/binary, "a">>)
end)(Size, <<>>),
Copy link
Collaborator

@WilliamVoong WilliamVoong Mar 17, 2026

Choose a reason for hiding this comment

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

I think its more idiomatic erlang and more readable to write

Suggested change
LargeBinary = (fun Loop(0, Acc) ->
Acc;
Loop(I, Acc) ->
Loop(I - 1, <<Acc/binary, "a">>)
end)(Size, <<>>),
LargeBinary = binary:copy("a", Size),

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Thanks! I wasn't aware of binary:copy/2.

@zuiderkwast
Copy link
Collaborator Author

Some more context. If we use blocking send, the process can become unresponsive and we can get a deadlock. See the discussion here: #157 (comment)

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.

3 participants