Skip to content

Commit fde7789

Browse files
committed
Merge branch 'fix-connector-bug' into crash-groups-guide
2 parents 963d330 + 6601c33 commit fde7789

4 files changed

Lines changed: 45 additions & 1 deletion

File tree

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
# Changelog
22

33
## Latest
4+
* Handle removed pads properly in `Membrane.Connector` [#1075](https://github.com/membraneframework/membrane_core/pull/1075)/
45
* Improve remove_link action docs
56
* Deprecate `:components` option for `:unsafely_name_processes_for_observer`
67
* Deprecate `:links` option for `:unsafely_name_processes_for_observer` in favour of `:report_links_to_observer` configuration entry

lib/membrane/connector.ex

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,12 @@ defmodule Membrane.Connector do
6060
{maybe_resume ++ maybe_flush, state}
6161
end
6262

63+
@impl true
64+
def handle_pad_removed(Pad.ref(direction, _ref), ctx, state) do
65+
state = state |> Map.put(direction, nil)
66+
maybe_pause_auto_demand(ctx, state)
67+
end
68+
6369
@impl true
6470
def handle_start_of_stream(_input_pad, ctx, state), do: maybe_pause_auto_demand(ctx, state)
6571

mix.exs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
defmodule Membrane.Mixfile do
22
use Mix.Project
33

4-
@version "1.2.6"
4+
@version "1.2.7"
55
@source_ref "v#{@version}"
66
@hex_packages_path "scripts/elixir/hex_packages.exs"
77

test/membrane/integration/connector_test.exs

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -123,4 +123,41 @@ defmodule Membrane.Integration.ConnectorTest do
123123

124124
[stream_format: %Format{field: 0}] ++ data
125125
end
126+
127+
test "Membrane.Connector doesn't raise after removing its pad" do
128+
crash_group_spec = {
129+
for i <- 2..5 do
130+
child({:connector, i}, Membrane.Connector)
131+
end,
132+
group: :my_group, crash_group_mode: :temporary
133+
}
134+
135+
children_beyond_crash_group = [
136+
child(:source, Testing.Source)
137+
|> child({:connector, 1}, Membrane.Connector),
138+
child({:connector, 6}, Membrane.Connector)
139+
|> child(:sink, Testing.Sink)
140+
]
141+
142+
connector_links =
143+
for i <- 1..5 do
144+
get_child({:connector, i})
145+
|> get_child({:connector, i + 1})
146+
end
147+
148+
spec = [crash_group_spec, children_beyond_crash_group, connector_links]
149+
pipeline = Testing.Pipeline.start_link_supervised!(spec: spec)
150+
151+
Process.sleep(200)
152+
153+
{:ok, connector_pid} = Testing.Pipeline.get_child_pid(pipeline, {:connector, 3})
154+
Process.exit(connector_pid, :kill)
155+
156+
Process.sleep(200)
157+
158+
assert Process.alive?(connector_pid) == false
159+
assert Process.alive?(pipeline)
160+
161+
Testing.Pipeline.terminate(pipeline)
162+
end
126163
end

0 commit comments

Comments
 (0)