Skip to content

Commit

Permalink
[ruby] improve possible error message in postfork parent (grpc#33791)
Browse files Browse the repository at this point in the history
The case of `!grpc_ruby_initial_pid()` can be a *cause* of the second
case, `!grpc_ruby_initial_thread`, so check the pid first.
  • Loading branch information
apolcyn authored Jul 20, 2023
1 parent 801f106 commit 3d9f2d8
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions src/ruby/ext/grpc/rb_grpc.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit 3d9f2d8

Please sign in to comment.