Skip to content

Commit 20b7d78

Browse files
committed
Merge remote-tracking branch 'origin/main' into chore/get-a-vm-running
# Conflicts: # lib/hyper/node/img/mutable.ex # lib/hyper/node/img/server.ex # lib/hyper/node/img/thin_pool.ex # lib/hyper/node/layer/server.ex # lib/mix/tasks/suidhelper.install.ex
2 parents 293293b + c4fbed3 commit 20b7d78

5 files changed

Lines changed: 45 additions & 14 deletions

File tree

lib/hyper/node/img/mutable.ex

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -121,9 +121,17 @@ defmodule Hyper.Node.Img.Mutable do
121121

122122
@impl true
123123
# Each privileged command runs through `System.cmd`, which links a transient
124-
# port to this process; because we trap exits (for `terminate/2` teardown),
125-
# the port's normal close is delivered here. Ignore it.
126-
def handle_info({:EXIT, _port, :normal}, state), do: {:noreply, state}
124+
# port to this process and returns only once that command has finished. Because
125+
# we trap exits (for `terminate/2` teardown), the now-defunct port's exit lands
126+
# here afterwards -- stale by construction, whatever its reason -- so ignore it.
127+
def handle_info({:EXIT, port, _reason}, state) when is_port(port), do: {:noreply, state}
128+
129+
@impl true
130+
# No process is deliberately linked here beyond those transient command ports,
131+
# so a linked *process* EXIT is a genuine fault: propagate its reason (so
132+
# terminate/2 still runs teardown) rather than crash opaquely on an unmatched
133+
# message.
134+
def handle_info({:EXIT, _pid, reason}, state), do: {:stop, reason, state}
127135

128136
@impl true
129137
def terminate(_reason, state) do

lib/hyper/node/img/server.ex

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -130,9 +130,17 @@ defmodule Hyper.Node.Img.Server do
130130

131131
@impl true
132132
# Each privileged command runs through `System.cmd`, which links a transient
133-
# port to this process; because we trap exits (for `terminate/2` teardown),
134-
# the port's normal close is delivered here. Ignore it.
135-
def handle_info({:EXIT, _port, :normal}, state), do: {:noreply, state}
133+
# port to this process and returns only once that command has finished. Because
134+
# we trap exits (for `terminate/2` teardown), the now-defunct port's exit lands
135+
# here afterwards -- stale by construction, whatever its reason -- so ignore it.
136+
def handle_info({:EXIT, port, _reason}, state) when is_port(port), do: {:noreply, state}
137+
138+
@impl true
139+
# No process is deliberately linked here beyond those transient command ports,
140+
# so a linked *process* EXIT is a genuine fault: propagate its reason (so
141+
# terminate/2 still runs teardown) rather than crash opaquely on an unmatched
142+
# message.
143+
def handle_info({:EXIT, _pid, reason}, state), do: {:stop, reason, state}
136144

137145
@impl true
138146
def terminate(_reason, %State{dm_names: dm_names}) do

lib/hyper/node/img/thin_pool.ex

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -96,10 +96,17 @@ defmodule Hyper.Node.Img.ThinPool do
9696

9797
@impl true
9898
# Each privileged command runs through `System.cmd`, which links a transient
99-
# port to this process; because we trap exits (for `terminate/2` teardown),
100-
# the port's normal close is delivered here. Ignore it. An abnormal exit
101-
# carries a non-`:normal` reason and falls through to the default handler.
102-
def handle_info({:EXIT, _port, :normal}, state), do: {:noreply, state}
99+
# port to this process and returns only once that command has finished. Because
100+
# we trap exits (for `terminate/2` teardown), the now-defunct port's exit lands
101+
# here afterwards -- stale by construction, whatever its reason -- so ignore it.
102+
def handle_info({:EXIT, port, _reason}, state) when is_port(port), do: {:noreply, state}
103+
104+
@impl true
105+
# No process is deliberately linked here beyond those transient command ports,
106+
# so a linked *process* EXIT is a genuine fault: propagate its reason (so
107+
# terminate/2 still runs teardown) rather than crash opaquely on an unmatched
108+
# message.
109+
def handle_info({:EXIT, _pid, reason}, state), do: {:stop, reason, state}
103110

104111
@impl true
105112
def terminate(_reason, state) do

lib/hyper/node/layer/server.ex

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -121,9 +121,17 @@ defmodule Hyper.Node.Layer.Server do
121121

122122
@impl true
123123
# Each privileged command runs through `System.cmd`, which links a transient
124-
# port to this process; because we trap exits (for `terminate/2` teardown),
125-
# the port's normal close is delivered here. Ignore it.
126-
def handle_info({:EXIT, _port, :normal}, state), do: {:noreply, state}
124+
# port to this process and returns only once that command has finished. Because
125+
# we trap exits (for `terminate/2` teardown), the now-defunct port's exit lands
126+
# here afterwards -- stale by construction, whatever its reason -- so ignore it.
127+
def handle_info({:EXIT, port, _reason}, state) when is_port(port), do: {:noreply, state}
128+
129+
@impl true
130+
# No process is deliberately linked here beyond those transient command ports,
131+
# so a linked *process* EXIT is a genuine fault: propagate its reason (so
132+
# terminate/2 still runs teardown) rather than crash opaquely on an unmatched
133+
# message.
134+
def handle_info({:EXIT, _pid, reason}, state), do: {:stop, reason, state}
127135

128136
@impl true
129137
def terminate(_reason, %State{blk_path: blk_path}) do

lib/mix/tasks/suidhelper.install.ex

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ defmodule Mix.Tasks.Suidhelper.Install do
2929

3030
@helper_dir "native/suidhelper"
3131
@source Path.join(@helper_dir, "target/release/hyper-suidhelper")
32-
# Must match `Hyper.Config`'s default `suid_helper` path and the xtask's
32+
# Must match `Hyper.Cfg.Tools.suidhelper/0`'s default path and the xtask's
3333
# `INSTALL_PATH`: a `PATH` location the unprivileged node can exec.
3434
@install_path "/usr/local/bin/hyper-suidhelper"
3535

0 commit comments

Comments
 (0)