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>>), quic_send(Stream, <<?PACKET_PONG>>),
{keep_state, State#state{ping_counter = PingCounter + 1}}; {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}) -> handle_event(info, {timeout, _, ping_ticker}, _, State = #state{client_id = ClientId, ping_counter = PingCounter}) ->
%% %%
erlang:start_timer(?PING_TICKER, self(), ping_ticker), 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>>), quic_send(Stream, <<?PACKET_COMMAND, CommandPkt/binary>>),
{keep_state, State#state{pkt_id = PktId + 1, pending_commands = maps:put(PktId, {Ref, ReceiverPid}, PendingCommands)}}; {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) -> handle_event(info, {'EXIT', _, _}, _StateName, State) ->
{stop, connection_closed, 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{}} |
{noreply, NewState :: #state{}, timeout() | hibernate} | {noreply, NewState :: #state{}, timeout() | hibernate} |
{stop, Reason :: term(), NewState :: #state{}}). {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), erlang:start_timer(100, self(), release_ticker),
AccReleaseCount = lists:foldl(fun(ThrottleKey, Acc) -> AccReleaseCount = lists:foldl(fun(ThrottleKey, Acc) ->
@ -103,7 +103,7 @@ handle_info({timeout, _, release_ticker}, State = #state{network_map = ChannelMa
{limit_exceeded, 0, _} -> {limit_exceeded, 0, _} ->
Acc Acc
end end
end, 0, maps:keys(ChannelMap)), end, 0, maps:values(NetworkMap)),
% logger:debug("[sdlan_network_coordinator] can release count is: ~p", [AccReleaseCount]), % logger:debug("[sdlan_network_coordinator] can release count is: ~p", [AccReleaseCount]),
{noreply, State#state{release_count = AccReleaseCount}}; {noreply, State#state{release_count = AccReleaseCount}};
handle_info({'DOWN', _, process, NetworkPid, Reason}, State = #state{network_map = NetworkMap}) -> handle_info({'DOWN', _, process, NetworkPid, Reason}, State = #state{network_map = NetworkMap}) ->

View File

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