Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,8 @@ at one version, so a release has a section in each changelog.
its own tmux server, and the root README shows `Server#explain_panes`,
`Server#run_group` and `Server#open_control`. `Server#explain_panes` has an
API example, which the docs site shows on its page.
- The Linux Async check detects pipes left open after a failed control launch
and verifies the same scope can open another connection. (#196)
- Timed-out or interrupted release checks clean up their child processes and
report the original failure without a reader-thread backtrace. (#176)
- Ruby programs on the recipes page can be copied into an empty directory and
Expand Down
42 changes: 22 additions & 20 deletions test/integration/async_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -744,35 +744,37 @@ def test_async_observer_failure_retains_and_reaps_its_real_child
end

def test_control_spawn_failure_is_reported_without_losing_admission
with_scope(control: true) do |scope, parent, fixture|
with_scope(control: true) do |_scope, parent, fixture|
executable = File.join(File.dirname(fixture.socket_path), "removed-async-client")
File.write(executable, "#!#{RbConfig.ruby} --disable=rubyopt,gems\nexec #{fixture.executable.inspect}, *ARGV\n")
File.chmod(0o700, executable)
LibTmux::Server.open(socket_path: fixture.socket_path, executable: executable) do |source|
ref = source.__send__(:build_entity, :session, "$0").ref
File.unlink(executable)
ref = source.list_sessions.first.ref
saved_executable = "#{executable}.saved"
File.rename(executable, saved_executable)
LibTmux::Async.open(parent: parent, server: source, max_controls: 1) do |isolated|
before = Dir.children("/dev/fd").length
resources = lambda do
Dir.children("/dev/fd").filter_map do |fd|
target = File.readlink("/dev/fd/#{fd}") rescue nil
[fd, target] if target&.match?(/\A(?:pipe|socket|anon_inode):/)
pipes = lambda do
Dir.children("/dev/fd").filter_map do |descriptor|
stat = File.stat("/dev/fd/#{descriptor}")
[descriptor, stat.dev, stat.ino] if stat.pipe?
rescue Errno::ENOENT, Errno::EBADF
nil
end
end
before_resources = resources.call
trace = TracePoint.new(:call) do |event|
if event.method_id == :spawn && event.self.class.name.end_with?("::ControlDriver")
::Async::Task.current.yield
end
2.times do
before = pipes.call
failure = assert_raises(LibTmux::TransportError) { isolated.server.open_control(session: ref) }
assert_equal :spawn, failure.phase
assert_equal :not_sent, failure.delivery
assert_nil failure.pid
refute_includes failure.message, executable
assert_empty pipes.call - before, "failed control startup left new pipes open"
end
trace.enable do
2.times do
failure = assert_raises(LibTmux::TransportError) { isolated.server.open_control(session: ref) }
assert_equal :not_sent, failure.delivery
refute_includes failure.message, executable
end

File.rename(saved_executable, executable)
isolated.server.open_control(session: ref) do |control|
assert_equal "recovered\n", control.exchange("display-message -p recovered").blocks.last.body
end
assert_equal before, Dir.children("/dev/fd").length, (resources.call - before_resources).inspect
end
end
end
Expand Down
Loading