-
Notifications
You must be signed in to change notification settings - Fork 39
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
Modify 5s linking timeout constraint #810
Merged
+82
−55
Merged
Changes from 10 commits
Commits
Show all changes
12 commits
Select commit
Hold shift + click to select a range
c3bb2fb
Modify 5s linking timeout constraint
FelonEkonom b200a4c
Make dialyzer happy
FelonEkonom e4cfff8
Maybe fix bug occuring in FishJam
FelonEkonom 814f10b
Fix linking timeout mechanism
FelonEkonom 7e06e70
Remove leftover
FelonEkonom 3abd3b5
Merge remote-tracking branch 'origin/master' into modify_5s_linking_c…
FelonEkonom 67ba8d2
Implement suggestions from CR & delete unnecessary state field
FelonEkonom a5890fc
Merge remote-tracking branch 'origin/master' into modify_5s_linking_c…
FelonEkonom d9ba128
Remove leftover
FelonEkonom 2ca56a7
Satisfy lint
FelonEkonom 8dac29a
with -> case
FelonEkonom b6b96fa
Merge branch 'master' into modify_5s_linking_constraint
FelonEkonom File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,6 +5,7 @@ defmodule Membrane.Core.Parent.ChildLifeController do | |
alias __MODULE__.{CrashGroupUtils, LinkUtils, StartupUtils} | ||
alias Membrane.{Child, ChildrenSpec} | ||
alias Membrane.Core.{Bin, CallbackHandler, Component, Parent, Pipeline} | ||
alias Membrane.Core.Bin.PadController | ||
|
||
alias Membrane.Core.Parent.{ | ||
ChildEntryParser, | ||
|
@@ -17,6 +18,7 @@ defmodule Membrane.Core.Parent.ChildLifeController do | |
alias Membrane.Pad | ||
alias Membrane.ParentError | ||
|
||
require Membrane.Core.Child.PadModel, as: PadModel | ||
require Membrane.Core.Component | ||
require Membrane.Core.Message, as: Message | ||
require Membrane.Logger | ||
|
@@ -154,7 +156,7 @@ defmodule Membrane.Core.Parent.ChildLifeController do | |
|
||
state = | ||
put_in(state, [:pending_specs, spec_ref], %{ | ||
status: :initializing, | ||
status: :created, | ||
children_names: MapSet.new(all_children_names), | ||
links_ids: Enum.map(links, & &1.id), | ||
dependent_specs: dependent_specs, | ||
|
@@ -309,14 +311,38 @@ defmodule Membrane.Core.Parent.ChildLifeController do | |
end | ||
end | ||
|
||
defp do_proceed_spec_startup(spec_ref, %{status: :created} = spec_data, state) do | ||
state = | ||
with %Bin.State{} <- state do | ||
bin_pads_linked_in_spec = | ||
spec_data.links_ids | ||
|> Enum.map(&Map.fetch!(state.links, &1)) | ||
|> Enum.flat_map(&[&1.from, &1.to]) | ||
|> Enum.flat_map(fn | ||
%{child: {Membrane.Bin, :itself}, pad_ref: pad_ref} -> [pad_ref] | ||
_other -> [] | ||
end) | ||
|
||
bin_pads_linked_in_spec | ||
|> Enum.reduce(state, fn pad_ref, state -> | ||
with {:error, :unknown_pad} <- PadModel.assert_instance(state, pad_ref) do | ||
PadController.init_pad_data(pad_ref, state) | ||
else | ||
:ok -> state | ||
end | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. a case would look better IMO |
||
|> PadModel.set_data!(pad_ref, :linked_in_spec?, true) | ||
end) | ||
end | ||
|
||
do_proceed_spec_startup(spec_ref, %{spec_data | status: :initializing}, state) | ||
end | ||
|
||
defp do_proceed_spec_startup(spec_ref, %{status: :initializing} = spec_data, state) do | ||
Membrane.Logger.debug( | ||
"Proceeding spec #{inspect(spec_ref)} startup: initializing, dependent specs: #{inspect(MapSet.to_list(spec_data.dependent_specs))}" | ||
) | ||
|
||
%{children: children} = state | ||
|
||
if Enum.all?(spec_data.children_names, &Map.fetch!(children, &1).initialized?) and | ||
if Enum.all?(spec_data.children_names, &Map.fetch!(state.children, &1).initialized?) and | ||
Enum.empty?(spec_data.dependent_specs) do | ||
Membrane.Logger.debug("Spec #{inspect(spec_ref)} status changed to initialized") | ||
do_proceed_spec_startup(spec_ref, %{spec_data | status: :initialized}, state) | ||
|
@@ -351,7 +377,7 @@ defmodule Membrane.Core.Parent.ChildLifeController do | |
end | ||
|
||
defp do_proceed_spec_startup(spec_ref, %{status: :linking_internally} = spec_data, state) do | ||
if Enum.empty?(spec_data.awaiting_responses) do | ||
if MapSet.size(spec_data.awaiting_responses) == 0 do | ||
state = | ||
spec_data.links_ids | ||
|> Enum.map(&Map.fetch!(state.links, &1)) | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why remove
pad_refs
? In case you forgot, it was added by yourself in this PR: #641 :PThere was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok, I didn't remember it 🙈 There was 1 place, where the pad was removed from
pads_data
but not frompad_refs
, so without this PR value stored under this field may be incorrec. I saw that nothing relies on the value of this field. I guess the reason of this field was to have more readable logs, but has anybody ever looked at it in the logs to debug something?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I didn't, but hard to say in general. I have the following idea:
inspect_pad_refs
and assign to it a function that will accept the state and return the pad refsMembrane.Core.Inspect
, if a field starts withinspect_
, we'll call the function in it instead of printing it directlyI don't like it much, but should be better than what we have. Otherwise I'd just remove this field, but it should be removed from the element as well
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
there is no such field in the element state