Skip to content

Add close/1 #81

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Jun 12, 2025
Merged

Add close/1 #81

merged 2 commits into from
Jun 12, 2025

Conversation

mickel8
Copy link
Member

@mickel8 mickel8 commented Jun 6, 2025

Add close/1 function.

This function irreversibly closes ICE agent but does not terminate its process. Later calls to getters (e.g. get_stats/1) are still allowed but the agent can no longer be used to establish a connection.

NOTE The best solution would be to modify ICE agent API to be similar to Erlang's :gen_udp API where, after closing a socket, :gen_udp functions return {:error, :closed} tuple. This however, would require a lot of changes. Other incorrect actions e.g. setting remote credentials in a wrong state, are also ignored i.e. no error is returned. If we find this problematic, we will modify ICE agent API in the future.

Related to: elixir-webrtc/ex_webrtc#218

@mickel8 mickel8 force-pushed the close branch 3 times, most recently from 981e9a0 to 7d09c8a Compare June 9, 2025 13:40
Copy link

codecov bot commented Jun 9, 2025

Codecov Report

Attention: Patch coverage is 58.13953% with 18 lines in your changes missing coverage. Please review.

Project coverage is 84.75%. Comparing base (7552d06) to head (c13e5ad).

Files with missing lines Patch % Lines
lib/ex_ice/priv/ice_agent.ex 55.00% 18 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master      #81      +/-   ##
==========================================
+ Coverage   83.88%   84.75%   +0.87%     
==========================================
  Files          25       25              
  Lines        1837     1870      +33     
==========================================
+ Hits         1541     1585      +44     
+ Misses        296      285      -11     
Files with missing lines Coverage Δ
lib/ex_ice/ice_agent.ex 65.75% <100.00%> (+4.32%) ⬆️
lib/ex_ice/priv/ice_agent.ex 85.92% <55.00%> (-0.16%) ⬇️

... and 2 files with indirect coverage changes


Continue to review full report in Codecov by Sentry.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 7552d06...c13e5ad. Read the comment docs.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@@ -455,7 +462,7 @@ defmodule ExICE.Priv.ICEAgent do
end

@spec end_of_candidates(t()) :: t()
def end_of_candidates(%__MODULE__{state: :failed} = ice_agent) do
def end_of_candidates(%__MODULE__{state: state} = ice_agent) when state in [:failed, :closed] do
Logger.debug("Can't set end-of-candidates flag in state failed. Ignoring.")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
Logger.debug("Can't set end-of-candidates flag in state failed. Ignoring.")
Logger.debug("Can't set end-of-candidates flag in state #{state}. Ignoring.")

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would ask a test that checks if all public functions in the ice agent won't change state if :closed

@mickel8 mickel8 merged commit 4854d81 into master Jun 12, 2025
4 of 6 checks passed
@mickel8 mickel8 deleted the close branch June 12, 2025 19:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants