Skip to content

Conversation

@viralpraxis
Copy link
Contributor

@viralpraxis viralpraxis commented Jul 17, 2025

Resolves #744

@bszaf
Copy link
Contributor

bszaf commented Jul 21, 2025

So based on #744 (comment)

It should be something like:

% The Erlang VM port forbids receiving TCP packets larger than 64MB
% https://github.com/erlang/otp/blob/359e254aba76c1986b671b45fd320c6cc6720ca8/erts/emulator/drivers/common/inet_drv.c#L1297
-define(MAX_PACKET_SIZE, 64 * 1024 * 1024).

% ....

recv(#client{transport=Transport, socket=Skt, recv_timeout=Timeout}, {BufSize, ExpectedSize}) when ExpectedSize >= BufSize ->
  Transport:recv(Skt, min(ExpectedSize - BufSize, ?MAX_PACKET_SIZE), Timeout);

@viralpraxis viralpraxis force-pushed the revert-body-parsing-optimization branch from d491e8f to 9e48d50 Compare July 21, 2025 16:36
@viralpraxis viralpraxis changed the title Revert body parsing optimization Respect TCP_MAX_PACKET_SIZE while reading response body Jul 21, 2025
@viralpraxis
Copy link
Contributor Author

So based on #744 (comment)

It should be something like:

% The Erlang VM port forbids receiving TCP packets larger than 64MB
% https://github.com/erlang/otp/blob/359e254aba76c1986b671b45fd320c6cc6720ca8/erts/emulator/drivers/common/inet_drv.c#L1297
-define(MAX_PACKET_SIZE, 64 * 1024 * 1024).

% ....

recv(#client{transport=Transport, socket=Skt, recv_timeout=Timeout}, {BufSize, ExpectedSize}) when ExpectedSize >= BufSize ->
  Transport:recv(Skt, min(ExpectedSize - BufSize, ?MAX_PACKET_SIZE), Timeout);

That's it, thanks! Just checked out with TCP_MAX_PACKET_SIZE limit and it works fine. Incrementing it by 1 leads to a enomem.

@viralpraxis
Copy link
Contributor Author

@benoitc could you take a look please?

@benoitc benoitc merged commit 436f7b2 into benoitc:master Jul 29, 2025
5 checks passed
@viralpraxis viralpraxis deleted the revert-body-parsing-optimization branch July 29, 2025 09:21
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.

Unexpected enomem error during file downloading

3 participants