Skip to content

Commit

Permalink
Fix flow control in erldns_udp_server (#134)
Browse files Browse the repository at this point in the history
Reset the {active, N} socket option only when receiving an udp_passive
message, rather than on every received packet, which provides no flow
control (and therefore no advantage over {active, true}).
  • Loading branch information
weiss authored Oct 16, 2024
1 parent b62ec69 commit a98561b
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions src/erldns_udp_server.erl
Original file line number Diff line number Diff line change
Expand Up @@ -101,11 +101,12 @@ handle_cast(_Message, State) ->

handle_info(timeout, State) ->
{noreply, State};
handle_info({udp_passive, _Socket}, State) ->
inet:setopts(State#state.socket, [{active, 100}]),
{noreply, State};
handle_info({udp, Socket, Host, Port, Bin}, State) ->
% lager:debug("Received request: ~p", [Bin]),
Response = folsom_metrics:histogram_timed_update(udp_handoff_histogram, ?MODULE, handle_request, [Socket, Host, Port, Bin, State]),
inet:setopts(State#state.socket, [{active, 100}]),
Response;
folsom_metrics:histogram_timed_update(udp_handoff_histogram, ?MODULE, handle_request, [Socket, Host, Port, Bin, State]);
handle_info(_Message, State) ->
{noreply, State}.

Expand Down

0 comments on commit a98561b

Please sign in to comment.