From d1143abaa8ca7f52ca4fb0b56e24401d69dcea95 Mon Sep 17 00:00:00 2001
From: Alexander Polcyn <apolcyn@google.com>
Date: Sun, 16 Apr 2017 10:26:44 -0700
Subject: [PATCH] tweak class init test to reveal bug in misordered startup

---
 src/ruby/end2end/grpc_class_init_client.rb | 23 +++++++++++++++++++++-
 1 file changed, 22 insertions(+), 1 deletion(-)

diff --git a/src/ruby/end2end/grpc_class_init_client.rb b/src/ruby/end2end/grpc_class_init_client.rb
index b321016b21..5fad1353be 100755
--- a/src/ruby/end2end/grpc_class_init_client.rb
+++ b/src/ruby/end2end/grpc_class_init_client.rb
@@ -29,7 +29,8 @@
 # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
 # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 
-# Try to catch if native gRPC class constructors are missing a 'grpc_init'
+# For GRPC::Core classes, which use the grpc c-core, object init
+# is interesting because it's related to overall library init.
 
 require_relative './end2end_common'
 
@@ -43,15 +44,35 @@ def main
 
   case grpc_class
   when 'channel'
+    thd = Thread.new do
+      GRPC::Core::Channel.new('dummy_host', nil, :this_channel_is_insecure)
+    end
     GRPC::Core::Channel.new('dummy_host', nil, :this_channel_is_insecure)
+    thd.join
   when 'server'
+    thd = Thread.new do
+      GRPC::Core::Server.new({})
+    end
     GRPC::Core::Server.new({})
+    thd.join
   when 'channel_credentials'
+    thd = Thread.new do
+      GRPC::Core::ChannelCredentials.new
+    end
     GRPC::Core::ChannelCredentials.new
+    thd.join
   when 'call_credentials'
+    thd = Thread.new do
+      GRPC::Core::CallCredentials.new(proc { |noop| noop })
+    end
     GRPC::Core::CallCredentials.new(proc { |noop| noop })
+    thd.join
   when 'compression_options'
+    thd = Thread.new do
+      GRPC::Core::CompressionOptions.new
+    end
     GRPC::Core::CompressionOptions.new
+    thd.join
   else
     fail "bad --grpc_class=#{grpc_class} param"
   end
-- 
GitLab