rb: Give the benchmark server more time to start up


git-svn-id: https://svn.apache.org/repos/asf/incubator/thrift/trunk@669029 13f79535-47bb-0310-9956-ffa450edef68
diff --git a/lib/rb/benchmark/benchmark.rb b/lib/rb/benchmark/benchmark.rb
index be3fc71..e6a1a3b 100644
--- a/lib/rb/benchmark/benchmark.rb
+++ b/lib/rb/benchmark/benchmark.rb
@@ -29,6 +29,8 @@
     return if @serverclass == Object
     args = (File.basename(@interpreter) == "jruby" ? "-J-server" : "")
     @pipe = IO.popen("#{@interpreter} #{args} #{File.dirname(__FILE__)}/server.rb #{@host} #{@port} #{@serverclass.name}", "r+")
+    Marshal.load(@pipe) # wait until the server has started
+    sleep 0.2 # give the server time to actually start spawning sockets
   end
 
   def shutdown
@@ -231,8 +233,6 @@
 server = Server.new(args)
 server.start
 
-sleep 0.2 # give the server time to start
-
 args = { :num_processes => 40, :clients_per_process => 5, :host => HOST, :port => PORT }
 args[:interpreter] = ENV['THRIFT_CLIENT_INTERPRETER'] || ENV['THRIFT_INTERPRETER'] || "ruby"
 BenchmarkManager.new(args, server).run
diff --git a/lib/rb/benchmark/server.rb b/lib/rb/benchmark/server.rb
index 91d42fa..e26e406 100644
--- a/lib/rb/benchmark/server.rb
+++ b/lib/rb/benchmark/server.rb
@@ -50,6 +50,10 @@
   const and const.split('::').inject(Object) { |k,c| k.const_get(c) }
 end
 
+# let our host know that the interpreter has started
+# ideally we'd wait until the server was serving, but we don't have a hook for that
+Marshal.dump(:started, STDOUT)
+
 host, port, serverklass = ARGV
 
 Server.start_server(host, port.to_i, resolve_const(serverklass))