1
#! /bin/sh /usr/share/dpatch/dpatch-run
3
## ruby-test-svnserve-race by <peter@p12n.org>
5
## DP: Hack to try to avoid the race in the ruby testsuite harness between
6
## DP: starting up a svnserve process and trying to connect to it. If the
7
## DP: client tries to connect too soon, before svnserve has initialised
8
## DP: itself, the test in progress gets a 'connection refused' and fails.
10
## DP: This race causes random test failures on slow platforms - observed on
11
## DP: an arm with 32 MB of RAM, and m68k buildds of unknown specs.
14
Index: subversion/bindings/swig/ruby/test/util.rb
15
--- a/subversion/bindings/swig/ruby/test/util.rb
16
+++ b/subversion/bindings/swig/ruby/test/util.rb
26
pid, status = Process.waitpid2(@svnserve_pid, Process::WNOHANG)
27
- if status and status.exited?
28
- STDERR.puts "port #{port} couldn't be used for svnserve"
30
+ if wait_until_svnserve_gets_available_at(port)
33
"svn://#{@svnserve_host}:#{@svnserve_port}#{@full_repos_path}"
35
auth_baton[Svn::Core::AUTH_PARAM_CONFIG_DIR] = @config_path
36
auth_baton[Svn::Core::AUTH_PARAM_DEFAULT_USERNAME] = @author
39
+ # Waits until svnserve gets available at port +port+, avoiding the race
40
+ # condition between starting up a svnserve process and trying to connect
41
+ # to it (Bug#378837 in Debian's BTS).
42
+ def wait_until_svnserve_gets_available_at(port)
45
+ pid, status = Process.waitpid2(@svnserve_pid, Process::WNOHANG)
46
+ if status and status.exited?
47
+ STDERR.puts "port #{port} couldn't be used for svnserve"
50
+ TCPSocket.new(@svnserve_host, port).close
51
+ rescue Errno::ECONNREFUSED
52
+ sleep(n < 10 ? 0.2 : 0.5)
57
+ raise "svnserve couldn't get available at port #{port}"