Skip to content

Commit

Permalink
Change socket backend to :socket. Optimize handle_channel_message
Browse files Browse the repository at this point in the history
  • Loading branch information
mickel8 committed Aug 16, 2023
1 parent 87c56c9 commit 83bb93b
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
2 changes: 1 addition & 1 deletion lib/rel/allocation_handler.ex
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ defmodule Rel.AllocationHandler do
end

@spec process_channel_message(GenServer.server(), term()) :: :ok
def process_channel_message(allocation, msg) do
def process_channel_message(allocation, msg) when is_binary(msg) do
GenServer.cast(allocation, {:channel_message, msg})
end

Expand Down
4 changes: 3 additions & 1 deletion lib/rel/listener.ex
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ defmodule Rel.Listener do
:gen_udp.open(
port,
[
{:inet_backend, :socket},
{:ifaddr, ip},
{:active, false},
{:recbuf, 1024 * 1024},
Expand Down Expand Up @@ -155,6 +156,7 @@ defmodule Rel.Listener do
:gen_udp.open(
alloc_port,
[
{:inet_backend, :socket},
{:ifaddr, relay_ip},
{:active, true},
{:recbuf, 1024 * 1024},
Expand Down Expand Up @@ -201,7 +203,7 @@ defmodule Rel.Listener do
end
end

defp handle_channel_message(five_tuple, msg) do
defp handle_channel_message(five_tuple, <<msg::binary>>) do
# TODO: are Registry entries removed fast enough?
case fetch_allocation(five_tuple) do
{:ok, alloc} ->
Expand Down

0 comments on commit 83bb93b

Please sign in to comment.