Skip to content

Commit

Permalink
Merge branch 'bmk/esock/20240906/socket_recv_done_before_done_win/OTP…
Browse files Browse the repository at this point in the history
…-19328' into maint
  • Loading branch information
bmk committed Oct 31, 2024
2 parents 4ab35a7 + 5feb983 commit 5a845dc
Showing 1 changed file with 19 additions and 2 deletions.
21 changes: 19 additions & 2 deletions lib/kernel/src/socket.erl
Original file line number Diff line number Diff line change
Expand Up @@ -5187,9 +5187,26 @@ recv_deadline(SockRef, Length, Flags, Deadline, Buf) ->
_ = cancel(SockRef, recv, Handle),
recv_error(Buf, timeout)
end;
%%
{ok, Bin} -> % All requested data


%% All requested data
{ok, Bin} when (Length =:= 0) orelse
(Length =:= byte_size(Bin)) -> % All requested data
{ok, condense_buffer([Bin | Buf])};

{ok, Bin} -> % Only part of the requested data
Timeout = timeout(Deadline),
if
0 < Timeout ->
%% Recv more
recv_deadline(
SockRef, Length - byte_size(Bin), Flags,
Deadline, [Bin | Buf]);
true ->
recv_error([Bin | Buf], timeout)
end;


%%
{error, Reason} ->
recv_error(Buf, Reason)
Expand Down

0 comments on commit 5a845dc

Please sign in to comment.