aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/ruby
diff options
context:
space:
mode:
authorGravatar Nicolas "Pixel" Noble <pixel@nobis-crew.org>2016-02-21 22:58:26 +0100
committerGravatar Nicolas "Pixel" Noble <pixel@nobis-crew.org>2016-02-21 22:58:26 +0100
commitcb90397216ea5d1eb82bc257e1263c9b606ed6f2 (patch)
tree26e6169529114bccdfed9c56479db97feeb4fb89 /src/ruby
parent6f4f02cf9f8d0b1a8dfa15e3f903b19a02ac9fdf (diff)
Adding the init / destruct of grpc for ruby in a gpr_once.
Diffstat (limited to 'src/ruby')
-rw-r--r--src/ruby/ext/grpc/rb_grpc.c11
1 files changed, 8 insertions, 3 deletions
diff --git a/src/ruby/ext/grpc/rb_grpc.c b/src/ruby/ext/grpc/rb_grpc.c
index 7344e1467c..996357c238 100644
--- a/src/ruby/ext/grpc/rb_grpc.c
+++ b/src/ruby/ext/grpc/rb_grpc.c
@@ -289,15 +289,20 @@ VALUE sym_code = Qundef;
VALUE sym_details = Qundef;
VALUE sym_metadata = Qundef;
+static gpr_once g_once_init = GPR_ONCE_INIT;
+
+static void grpc_ruby_once_init() {
+ grpc_init();
+ atexit(grpc_rb_shutdown);
+}
+
void Init_grpc_c() {
if (!grpc_rb_load_core()) {
rb_raise(rb_eLoadError, "Couldn't find or load gRPC's dynamic C core");
return;
}
- grpc_init();
-
- atexit(grpc_rb_shutdown);
+ gpr_once_init(&g_once_init, grpc_ruby_once_init);
grpc_rb_mGRPC = rb_define_module("GRPC");
grpc_rb_mGrpcCore = rb_define_module_under(grpc_rb_mGRPC, "Core");