Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

added max chunk check on recv #460

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

seanmcevoy
Copy link

@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
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