From 3d9f2d8f77a65fe803035580a6f8786f0cb0db77 Mon Sep 17 00:00:00 2001 From: apolcyn Date: Thu, 20 Jul 2023 13:47:13 -0700 Subject: [PATCH] [ruby] improve possible error message in postfork parent (#33791) The case of `!grpc_ruby_initial_pid()` can be a *cause* of the second case, `!grpc_ruby_initial_thread`, so check the pid first. --- src/ruby/ext/grpc/rb_grpc.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/ruby/ext/grpc/rb_grpc.c b/src/ruby/ext/grpc/rb_grpc.c index ebc52f3f6a802..30281b54630ae 100644 --- a/src/ruby/ext/grpc/rb_grpc.c +++ b/src/ruby/ext/grpc/rb_grpc.c @@ -429,16 +429,16 @@ static VALUE grpc_rb_postfork_parent(VALUE self) { "GRPC::postfork_parent can only be called once following a " "GRPC::prefork"); } - if (!grpc_ruby_initial_thread()) { - rb_raise(rb_eRuntimeError, - "GRPC.postfork_parent needs to be called from the same thread " - "that GRPC.prefork (and fork) was called from"); - } if (!grpc_ruby_initial_pid()) { rb_raise(rb_eRuntimeError, "GRPC.postfork_parent must be called only from the parent process " "after a fork"); } + if (!grpc_ruby_initial_thread()) { + rb_raise(rb_eRuntimeError, + "GRPC.postfork_parent needs to be called from the same thread " + "that GRPC.prefork (and fork) was called from"); + } grpc_ruby_init_threads(); g_grpc_rb_prefork_pending = false; return Qnil;