From fd4eba7f3a430ec428aa67fb7fb85c4e42d389a3 Mon Sep 17 00:00:00 2001 From: Dimitris Christodoulou Date: Thu, 27 Aug 2026 11:28:40 +0100 Subject: [PATCH] Update C++ core to eddf27b --- ext/couchbase | 2 +- test/couchbase_test.rb | 26 +++++++++++++++++++++++++- 2 files changed, 26 insertions(+), 2 deletions(-) diff --git a/ext/couchbase b/ext/couchbase index 99397bbf..eddf27b5 160000 --- a/ext/couchbase +++ b/ext/couchbase @@ -1 +1 @@ -Subproject commit 99397bbffb64392157a23614429ea8fa9ec22e3a +Subproject commit eddf27b54c6717fee41e488e8bfbfcfbcf6e734c diff --git a/test/couchbase_test.rb b/test/couchbase_test.rb index ab3b2fd5..a0e7688c 100644 --- a/test/couchbase_test.rb +++ b/test/couchbase_test.rb @@ -50,6 +50,8 @@ def test_it_can_use_configuration_with_connect end end + FORK_CHILD_TIMEOUT = 30 + # Regression test for RCBC-550 def test_it_can_connect_after_process_fork skip("Forking not supported on Windows") if Gem.win_platform? @@ -64,7 +66,7 @@ def test_it_can_connect_after_process_fork cluster.disconnect end - _, status = Process.wait2(pid) + status = wait_for_child_or_kill(pid, timeout: FORK_CHILD_TIMEOUT) assert_predicate status, :success?, "Child process failed with status #{status.exitstatus}" @@ -74,4 +76,26 @@ def test_it_can_connect_after_process_fork refute_nil cluster cluster.disconnect end + + private + + # Polls for +pid+ to exit, killing it and failing the test if it doesn't within + # +timeout+ seconds, instead of blocking forever like Process.wait2 would. + def wait_for_child_or_kill(pid, timeout:) + deadline = Process.clock_gettime(Process::CLOCK_MONOTONIC) + timeout + + loop do + _, status = Process.waitpid2(pid, Process::WNOHANG) + return status if status + + if Process.clock_gettime(Process::CLOCK_MONOTONIC) > deadline + Process.kill("KILL", pid) + Process.waitpid2(pid) + + flunk "Child process (pid #{pid}) did not exit within #{timeout}s after fork." + end + + sleep 0.1 + end + end end