Skip to content

Commit

Permalink
Don't crash on redundant network present notifications
Browse files Browse the repository at this point in the history
These really shouldn't happen much, but I saw what that did and it
seemed like crashing was too harsh.
  • Loading branch information
fhunleth committed Nov 13, 2022
1 parent 5bfc9bf commit cbda23b
Showing 1 changed file with 15 additions and 2 deletions.
17 changes: 15 additions & 2 deletions lib/vintage_net/interface.ex
Original file line number Diff line number Diff line change
Expand Up @@ -449,11 +449,11 @@ defmodule VintageNet.Interface do
@impl GenStateMachine
def handle_event(
:info,
{VintageNet, ["interface", an_ifname, "present"], _old_value, nil, _meta},
{VintageNet, ["interface", ifname, "present"], _old_value, nil, _meta},
:configured,
%State{config: config} = data
) do
debug(data, ":configured -> #{an_ifname} removed")
debug(data, ":configured -> #{ifname} removed, so reconfiguring")

{new_data, actions} = cancel_ioctls(data)
VintageNet.Interface.Supervisor.clear_technology(data.ifname)
Expand All @@ -467,6 +467,19 @@ defmodule VintageNet.Interface do
{:next_state, :reconfiguring, %{new_data | next_config: config}, actions}
end

@impl GenStateMachine
def handle_event(
:info,
{VintageNet, ["interface", ifname, "present"], _old_value, true, _meta},
:configured,
data
) do
# Ignore redundant notifications - could be due to restarts, old messages in
# in queues, etc.
debug(data, ":configured -> ignoring #{ifname} present notification")
{:keep_state, data}
end

# :reconfiguring

@impl GenStateMachine
Expand Down

0 comments on commit cbda23b

Please sign in to comment.