diff --git a/lib/openflow/enums.ex b/lib/openflow/enums.ex index 7ea33b5..58cf0a0 100644 --- a/lib/openflow/enums.ex +++ b/lib/openflow/enums.ex @@ -993,20 +993,22 @@ defmodule Openflow.Enums do to_int_fn_name = String.to_atom(enum_name <> "_to_int") to_atom_fn_name = String.to_atom(enum_name <> "_to_atom") - for {key, value} <- enum_def do + for {key, _value} <- enum_def do def to_int(unquote(key), unquote(String.to_atom(enum_name))) do try do unquote(to_int_fn_name)(unquote(key)) catch - _ -> unquote(key) + :throw, _ -> unquote(key) end end + end + for {_key, value} <- enum_def do def to_atom(unquote(value), unquote(String.to_atom(enum_name))) do try do unquote(to_atom_fn_name)(unquote(value)) catch - _ -> unquote(value) + :throw, _ -> unquote(value) end end end diff --git a/lib/tres/controller.ex b/lib/tres/controller.ex index 15cdaa1..92d962e 100644 --- a/lib/tres/controller.ex +++ b/lib/tres/controller.ex @@ -1,10 +1,11 @@ defmodule Tres.Controller do def controller_helpers do quote do - import Tres.SwitchRegistry, only: [ - send_message: 2, - get_current_xid: 1 - ] + import Tres.SwitchRegistry, + only: [ + send_message: 2, + get_current_xid: 1 + ] use Tres.Messages use Tres.MessageHelper diff --git a/lib/tres/secure_channel.ex b/lib/tres/secure_channel.ex index d0c028b..80e41c0 100644 --- a/lib/tres/secure_channel.ex +++ b/lib/tres/secure_channel.ex @@ -124,10 +124,12 @@ defmodule Tres.SecureChannel do defp init_handler(state_data) do %State{datapath_id: dpid, aux_id: aux_id} = state_data + case MessageHandlerSup.start_child({dpid, aux_id}) do {:ok, pid} -> ref = Process.monitor(pid) %{state_data | handler_pid: pid, handler_ref: ref} + {:error, reason} -> {:stop, reason} end @@ -210,6 +212,7 @@ defmodule Tres.SecureChannel do %State{} = new_state_data -> start_periodic_idle_check() {:keep_state, new_state_data} + {:stop, reason} -> close_connection({:handler_down, reason}, state_data) end diff --git a/lib/tres/switch_registry.ex b/lib/tres/switch_registry.ex index 7fafd99..e901fe5 100644 --- a/lib/tres/switch_registry.ex +++ b/lib/tres/switch_registry.ex @@ -27,7 +27,7 @@ defmodule Tres.SwitchRegistry do end def get_current_xid({_dpid, _aux_id} = datapath_id) do - [{pid, _}|_] = Registry.lookup(__MODULE__, datapath_id) + [{pid, _} | _] = Registry.lookup(__MODULE__, datapath_id) :gen_statem.call(pid, :get_xid, 1000) end