-
Notifications
You must be signed in to change notification settings - Fork 0
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
Use active socket #6
Conversation
raise "TCP Socket receiving error, reason: #{inspect(reason)}" | ||
end | ||
def handle_demand(_pad, size, _unit, _ctx, state) do | ||
:inet.setopts(state.local_socket.socket_handle, active: size) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This makes sense if only if the demand unit is buffers, you can enforce it in def_output_pad
lib/membrane_tcp/source.ex
Outdated
} | ||
|
||
{ | ||
[buffer: {:output, %Buffer{payload: payload, metadata: metadata}}, redemand: :output], |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
since we request the same amount of buffers from TCP that is demanded, the redemand is not needed
This PR modifies the Source so that it relies on a
:gen_tcp
socket using active mode rather than non-active, since the latter seems to use a lot more CPU in our implmentation, especially where the demand is higher than supply. To keep the flow control features the socket is using theactive: :once
oractive: N
, which limits the amount of messages that the element will receive before returning toactive: false
state.