Skip to content

Commit 1324219

Browse files
committed
Update the connection state after all actions that may affect it
1 parent fb8e5da commit 1324219

File tree

2 files changed

+7
-10
lines changed

2 files changed

+7
-10
lines changed

lib/ex_ice/priv/ice_agent.ex

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -485,7 +485,9 @@ defmodule ExICE.Priv.ICEAgent do
485485
Logger.debug("Setting end-of-candidates flag.")
486486
ice_agent = %{ice_agent | eoc: true}
487487
# check whether it's time to nominate and if yes, try noimnate
488-
maybe_nominate(ice_agent)
488+
ice_agent
489+
|> maybe_nominate()
490+
|> update_connection_state()
489491
end
490492

491493
@spec send_data(t(), binary()) :: t()
@@ -580,6 +582,7 @@ defmodule ExICE.Priv.ICEAgent do
580582
|> update_gathering_state()
581583
|> update_connection_state()
582584
|> maybe_nominate()
585+
|> update_connection_state()
583586

584587
if ice_agent.state in [:completed, :failed] do
585588
update_ta_timer(ice_agent)
@@ -591,7 +594,9 @@ defmodule ExICE.Priv.ICEAgent do
591594
ice_agent
592595

593596
{type, tr} ->
594-
execute_transaction(ice_agent, type, tr)
597+
ice_agent
598+
|> execute_transaction(type, tr)
599+
|> update_connection_state()
595600
end
596601

597602
# schedule next check and call update_ta_timer

test/priv/ice_agent_test.exs

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1592,8 +1592,6 @@ defmodule ExICE.Priv.ICEAgentTest do
15921592
# try to send conn check
15931593
ice_agent = ICEAgent.handle_ta_timeout(ice_agent)
15941594

1595-
assert ice_agent.state == :checking
1596-
15971595
# assert that the candidate pair has moved to a failed state
15981596
# and that the state was updated after the packet was discarded
15991597
assert [
@@ -1605,8 +1603,6 @@ defmodule ExICE.Priv.ICEAgentTest do
16051603
}
16061604
] = Map.values(ice_agent.checklist)
16071605

1608-
ice_agent = ICEAgent.handle_ta_timeout(ice_agent)
1609-
16101606
assert ice_agent.state == :failed
16111607
end
16121608

@@ -1650,10 +1646,6 @@ defmodule ExICE.Priv.ICEAgentTest do
16501646
}
16511647
] = Map.values(ice_agent.checklist)
16521648

1653-
assert ice_agent.state == :connected
1654-
1655-
ice_agent = ICEAgent.handle_ta_timeout(ice_agent)
1656-
16571649
assert ice_agent.state == :failed
16581650
end
16591651
end

0 commit comments

Comments
 (0)