Skip to content

added max chunk check on recv#460

Open
seanmcevoy wants to merge 1 commit into
erlyaws:masterfrom
seanmcevoy:2.1.0_max_chunk_fix
Open

added max chunk check on recv#460
seanmcevoy wants to merge 1 commit into
erlyaws:masterfrom
seanmcevoy:2.1.0_max_chunk_fix

Conversation

@seanmcevoy
Copy link
Copy Markdown

@seanmcevoy seanmcevoy commented Oct 5, 2022

this fix allows yaws to receive data over 64MB in size.
open an erlang shell, start a tcp listener, send 256M + 1B and connect to it with:

spawn(fun() ->
{ok,LS} = gen_tcp:listen(3456,[{reuseaddr, true}, {active, false}, binary]),
{ok,SS} = gen_tcp:accept(LS),
gen_tcp:send(SS,crypto:strong_rand_bytes((4 * 64 * 1024 * 1024) + 1)),
receive stop -> ok end
end).
{ok,RS} = gen_tcp:connect("localhost",3456,[{reuseaddr, true}, {active, false}, binary]).

then on the receive side note that this can only be consumed in chunks of 64MB or less:
gen_tcp:recv(SS, (64 * 1024 * 1024) + 0, 1000).
gen_tcp:recv(SS, (64 * 1024 * 1024) + 1, 1000).
gen_tcp:recv(RS, (64 * 1024 * 1024) + 0, 1000).
gen_tcp:recv(RS, (64 * 1024 * 1024) + 1, 1000).
gen_tcp:recv(RS, (64 * 1024 * 1024) + 0, 1000).
gen_tcp:recv(RS, (64 * 1024 * 1024) + 1, 1000).
gen_tcp:recv(RS, (64 * 1024 * 1024) + 0, 1000).
gen_tcp:recv(RS, (64 * 1024 * 1024) + 1, 1000).
gen_tcp:recv(RS, 1, 1000).

in our application all uploads of files greater than 64MB fail with enomem in the same way as demonstrated here.
this change works in our application at least.

@avtobiff
Copy link
Copy Markdown
Collaborator

Thanks for your PR!

Please add a test for the new behaviour.

Please write a longer commit message describing the change.
(Parts of the PR's description are good candidates of info
describing the reason and method for the change.)

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