Skip to content

Commit

Permalink
[kernel|esock] Check if actually done when recv
Browse files Browse the repository at this point in the history
Make sure that we have actually received all data before we return.
This is a Windows only issue.

OTP-19328
  • Loading branch information
bmk committed Oct 28, 2024
1 parent 601a012 commit 5feb983
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 @@ -5169,9 +5169,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 5feb983

Please sign in to comment.