This commit is contained in:
anlicheng 2026-04-13 15:12:01 +08:00
parent e6163c06cc
commit 5bc5b5ebe3
3 changed files with 16 additions and 16 deletions

View File

@ -328,6 +328,12 @@ handle_event(internal, {frame, <<?PACKET_PING>>}, _StateName, State = #state{str
quic_send(Stream, <<?PACKET_PONG>>),
{keep_state, State#state{ping_counter = PingCounter + 1}};
%%
handle_event(internal, {frame, <<?PACKET_UNREGISTER>>}, registered, State=#state{client_id = ClientId, mac = Mac, network_pid = NetworkPid}) when is_pid(NetworkPid) ->
logger:warning("[sdlan_channel] unregister client_id: ~p", [ClientId]),
sdlan_network:unregister(NetworkPid, ClientId, Mac),
{stop, normal, State};
handle_event(info, {timeout, _, ping_ticker}, _, State = #state{client_id = ClientId, ping_counter = PingCounter}) ->
%%
erlang:start_timer(?PING_TICKER, self(), ping_ticker),
@ -355,12 +361,6 @@ handle_event(cast, {command, Ref, ReceiverPid, SubCommand}, registered, State=#s
quic_send(Stream, <<?PACKET_COMMAND, CommandPkt/binary>>),
{keep_state, State#state{pkt_id = PktId + 1, pending_commands = maps:put(PktId, {Ref, ReceiverPid}, PendingCommands)}};
%%
handle_event(info, {frame, <<?PACKET_UNREGISTER>>}, registered, State=#state{client_id = ClientId, mac = Mac, network_pid = NetworkPid}) when is_pid(NetworkPid) ->
logger:warning("[sdlan_channel] unregister client_id: ~p", [ClientId]),
sdlan_network:unregister(NetworkPid, ClientId, Mac),
{stop, normal, State};
handle_event(info, {'EXIT', _, _}, _StateName, State) ->
{stop, connection_closed, State};

View File

@ -91,7 +91,7 @@ handle_cast({attach, NetworkPid, ThrottleKey}, State = #state{network_map = Netw
{noreply, NewState :: #state{}} |
{noreply, NewState :: #state{}, timeout() | hibernate} |
{stop, Reason :: term(), NewState :: #state{}}).
handle_info({timeout, _, release_ticker}, State = #state{network_map = ChannelMap}) ->
handle_info({timeout, _, release_ticker}, State = #state{network_map = NetworkMap}) ->
%%
erlang:start_timer(100, self(), release_ticker),
AccReleaseCount = lists:foldl(fun(ThrottleKey, Acc) ->
@ -103,7 +103,7 @@ handle_info({timeout, _, release_ticker}, State = #state{network_map = ChannelMa
{limit_exceeded, 0, _} ->
Acc
end
end, 0, maps:keys(ChannelMap)),
end, 0, maps:values(NetworkMap)),
% logger:debug("[sdlan_network_coordinator] can release count is: ~p", [AccReleaseCount]),
{noreply, State#state{release_count = AccReleaseCount}};
handle_info({'DOWN', _, process, NetworkPid, Reason}, State = #state{network_map = NetworkMap}) ->

View File

@ -30,14 +30,14 @@ init([]) ->
Specs = [
%% dns的逻辑
% #{
% id => dns_proxy_sup,
% start => {dns_proxy_sup, start_link, []},
% restart => permanent,
% shutdown => 2000,
% type => supervisor,
% modules => ['dns_proxy_sup']
% },
#{
id => dns_server_sup,
start => {dns_server_sup, start_link, []},
restart => permanent,
shutdown => 2000,
type => supervisor,
modules => ['dns_server_sup']
},
#{
id => sdlan_network_coordinator,
start => {sdlan_network_coordinator, start_link, []},