grpc 1.7.3-x86-linux → 1.8.0-x86-linux
Sign up to get free protection for your applications and to get access to all the features.
Potentially problematic release.
This version of grpc might be problematic. Click here for more details.
- checksums.yaml +4 -4
- data/grpc_c.32.ruby +0 -0
- data/grpc_c.64.ruby +0 -0
- data/src/ruby/ext/grpc/extconf.rb +4 -2
- data/src/ruby/ext/grpc/rb_byte_buffer.c +5 -5
- data/src/ruby/ext/grpc/rb_byte_buffer.h +2 -2
- data/src/ruby/ext/grpc/rb_call.c +41 -42
- data/src/ruby/ext/grpc/rb_call.h +6 -6
- data/src/ruby/ext/grpc/rb_call_credentials.c +30 -30
- data/src/ruby/ext/grpc/rb_channel.c +87 -87
- data/src/ruby/ext/grpc/rb_channel_credentials.c +23 -23
- data/src/ruby/ext/grpc/rb_completion_queue.c +11 -11
- data/src/ruby/ext/grpc/rb_completion_queue.h +3 -3
- data/src/ruby/ext/grpc/rb_compression_options.c +20 -20
- data/src/ruby/ext/grpc/rb_event_thread.c +14 -14
- data/src/ruby/ext/grpc/rb_event_thread.h +1 -1
- data/src/ruby/ext/grpc/rb_grpc.c +8 -8
- data/src/ruby/ext/grpc/rb_grpc_imports.generated.c +16 -58
- data/src/ruby/ext/grpc/rb_grpc_imports.generated.h +242 -306
- data/src/ruby/ext/grpc/rb_server.c +23 -23
- data/src/ruby/ext/grpc/rb_server_credentials.c +13 -13
- data/src/ruby/lib/grpc/2.0/grpc_c.so +0 -0
- data/src/ruby/lib/grpc/2.1/grpc_c.so +0 -0
- data/src/ruby/lib/grpc/2.2/grpc_c.so +0 -0
- data/src/ruby/lib/grpc/2.3/grpc_c.so +0 -0
- data/src/ruby/lib/grpc/2.4/grpc_c.so +0 -0
- data/src/ruby/lib/grpc/generic/rpc_server.rb +25 -12
- data/src/ruby/lib/grpc/grpc_c.so +0 -0
- data/src/ruby/lib/grpc/version.rb +1 -1
- data/src/ruby/pb/grpc/health/checker.rb +14 -0
- data/src/ruby/spec/pb/health/checker_spec.rb +29 -0
- metadata +2 -2
@@ -54,9 +54,9 @@ static VALUE grpc_rb_cChannel = Qnil;
|
|
54
54
|
static VALUE grpc_rb_cChannelArgs;
|
55
55
|
|
56
56
|
typedef struct bg_watched_channel {
|
57
|
-
grpc_channel
|
57
|
+
grpc_channel* channel;
|
58
58
|
// these fields must only be accessed under global_connection_polling_mu
|
59
|
-
struct bg_watched_channel
|
59
|
+
struct bg_watched_channel* next;
|
60
60
|
int channel_destroyed;
|
61
61
|
int refcount;
|
62
62
|
} bg_watched_channel;
|
@@ -67,7 +67,7 @@ typedef struct grpc_rb_channel {
|
|
67
67
|
|
68
68
|
/* The actual channel (protected in a wrapper to tell when it's safe to
|
69
69
|
* destroy) */
|
70
|
-
bg_watched_channel
|
70
|
+
bg_watched_channel* bg_wrapped;
|
71
71
|
} grpc_rb_channel;
|
72
72
|
|
73
73
|
typedef enum { CONTINUOUS_WATCH, WATCH_STATE_API } watch_state_op_type;
|
@@ -82,40 +82,40 @@ typedef struct watch_state_op {
|
|
82
82
|
int called_back;
|
83
83
|
} api_callback_args;
|
84
84
|
struct {
|
85
|
-
bg_watched_channel
|
85
|
+
bg_watched_channel* bg;
|
86
86
|
} continuous_watch_callback_args;
|
87
87
|
} op;
|
88
88
|
} watch_state_op;
|
89
89
|
|
90
|
-
static bg_watched_channel
|
90
|
+
static bg_watched_channel* bg_watched_channel_list_head = NULL;
|
91
91
|
|
92
92
|
static void grpc_rb_channel_try_register_connection_polling(
|
93
|
-
bg_watched_channel
|
94
|
-
static void
|
95
|
-
static void wait_until_channel_polling_thread_started_unblocking_func(void
|
96
|
-
static void
|
97
|
-
void
|
93
|
+
bg_watched_channel* bg);
|
94
|
+
static void* wait_until_channel_polling_thread_started_no_gil(void*);
|
95
|
+
static void wait_until_channel_polling_thread_started_unblocking_func(void*);
|
96
|
+
static void* channel_init_try_register_connection_polling_without_gil(
|
97
|
+
void* arg);
|
98
98
|
|
99
99
|
typedef struct channel_init_try_register_stack {
|
100
|
-
grpc_channel
|
101
|
-
grpc_rb_channel
|
100
|
+
grpc_channel* channel;
|
101
|
+
grpc_rb_channel* wrapper;
|
102
102
|
} channel_init_try_register_stack;
|
103
103
|
|
104
|
-
static grpc_completion_queue
|
104
|
+
static grpc_completion_queue* channel_polling_cq;
|
105
105
|
static gpr_mu global_connection_polling_mu;
|
106
106
|
static gpr_cv global_connection_polling_cv;
|
107
107
|
static int abort_channel_polling = 0;
|
108
108
|
static int channel_polling_thread_started = 0;
|
109
109
|
|
110
|
-
static int bg_watched_channel_list_lookup(bg_watched_channel
|
111
|
-
static bg_watched_channel
|
112
|
-
grpc_channel
|
113
|
-
static void bg_watched_channel_list_free_and_remove(bg_watched_channel
|
114
|
-
static void run_poll_channels_loop_unblocking_func(void
|
110
|
+
static int bg_watched_channel_list_lookup(bg_watched_channel* bg);
|
111
|
+
static bg_watched_channel* bg_watched_channel_list_create_and_add(
|
112
|
+
grpc_channel* channel);
|
113
|
+
static void bg_watched_channel_list_free_and_remove(bg_watched_channel* bg);
|
114
|
+
static void run_poll_channels_loop_unblocking_func(void* arg);
|
115
115
|
|
116
116
|
// Needs to be called under global_connection_polling_mu
|
117
117
|
static void grpc_rb_channel_watch_connection_state_op_complete(
|
118
|
-
watch_state_op
|
118
|
+
watch_state_op* op, int success) {
|
119
119
|
GPR_ASSERT(!op->op.api_callback_args.called_back);
|
120
120
|
op->op.api_callback_args.called_back = 1;
|
121
121
|
op->op.api_callback_args.success = success;
|
@@ -124,7 +124,7 @@ static void grpc_rb_channel_watch_connection_state_op_complete(
|
|
124
124
|
}
|
125
125
|
|
126
126
|
/* Avoids destroying a channel twice. */
|
127
|
-
static void grpc_rb_channel_safe_destroy(bg_watched_channel
|
127
|
+
static void grpc_rb_channel_safe_destroy(bg_watched_channel* bg) {
|
128
128
|
gpr_mu_lock(&global_connection_polling_mu);
|
129
129
|
GPR_ASSERT(bg_watched_channel_list_lookup(bg));
|
130
130
|
if (!bg->channel_destroyed) {
|
@@ -138,18 +138,18 @@ static void grpc_rb_channel_safe_destroy(bg_watched_channel *bg) {
|
|
138
138
|
gpr_mu_unlock(&global_connection_polling_mu);
|
139
139
|
}
|
140
140
|
|
141
|
-
static void
|
142
|
-
grpc_rb_channel_safe_destroy((bg_watched_channel
|
141
|
+
static void* channel_safe_destroy_without_gil(void* arg) {
|
142
|
+
grpc_rb_channel_safe_destroy((bg_watched_channel*)arg);
|
143
143
|
return NULL;
|
144
144
|
}
|
145
145
|
|
146
146
|
/* Destroys Channel instances. */
|
147
|
-
static void grpc_rb_channel_free(void
|
148
|
-
grpc_rb_channel
|
147
|
+
static void grpc_rb_channel_free(void* p) {
|
148
|
+
grpc_rb_channel* ch = NULL;
|
149
149
|
if (p == NULL) {
|
150
150
|
return;
|
151
151
|
};
|
152
|
-
ch = (grpc_rb_channel
|
152
|
+
ch = (grpc_rb_channel*)p;
|
153
153
|
|
154
154
|
if (ch->bg_wrapped != NULL) {
|
155
155
|
/* assumption made here: it's ok to directly gpr_mu_lock the global
|
@@ -164,12 +164,12 @@ static void grpc_rb_channel_free(void *p) {
|
|
164
164
|
}
|
165
165
|
|
166
166
|
/* Protects the mark object from GC */
|
167
|
-
static void grpc_rb_channel_mark(void
|
168
|
-
grpc_rb_channel
|
167
|
+
static void grpc_rb_channel_mark(void* p) {
|
168
|
+
grpc_rb_channel* channel = NULL;
|
169
169
|
if (p == NULL) {
|
170
170
|
return;
|
171
171
|
}
|
172
|
-
channel = (grpc_rb_channel
|
172
|
+
channel = (grpc_rb_channel*)p;
|
173
173
|
if (channel->credentials != Qnil) {
|
174
174
|
rb_gc_mark(channel->credentials);
|
175
175
|
}
|
@@ -189,7 +189,7 @@ static rb_data_type_t grpc_channel_data_type = {"grpc_channel",
|
|
189
189
|
|
190
190
|
/* Allocates grpc_rb_channel instances. */
|
191
191
|
static VALUE grpc_rb_channel_alloc(VALUE cls) {
|
192
|
-
grpc_rb_channel
|
192
|
+
grpc_rb_channel* wrapper = ALLOC(grpc_rb_channel);
|
193
193
|
wrapper->bg_wrapped = NULL;
|
194
194
|
wrapper->credentials = Qnil;
|
195
195
|
return TypedData_Wrap_Struct(cls, &grpc_channel_data_type, wrapper);
|
@@ -203,14 +203,14 @@ static VALUE grpc_rb_channel_alloc(VALUE cls) {
|
|
203
203
|
secure_channel = Channel:new("myhost:443", {'arg1': 'value1'}, creds)
|
204
204
|
|
205
205
|
Creates channel instances. */
|
206
|
-
static VALUE grpc_rb_channel_init(int argc, VALUE
|
206
|
+
static VALUE grpc_rb_channel_init(int argc, VALUE* argv, VALUE self) {
|
207
207
|
VALUE channel_args = Qnil;
|
208
208
|
VALUE credentials = Qnil;
|
209
209
|
VALUE target = Qnil;
|
210
|
-
grpc_rb_channel
|
211
|
-
grpc_channel
|
212
|
-
grpc_channel_credentials
|
213
|
-
char
|
210
|
+
grpc_rb_channel* wrapper = NULL;
|
211
|
+
grpc_channel* ch = NULL;
|
212
|
+
grpc_channel_credentials* creds = NULL;
|
213
|
+
char* target_chars = NULL;
|
214
214
|
grpc_channel_args args;
|
215
215
|
channel_init_try_register_stack stack;
|
216
216
|
int stop_waiting_for_thread_start = 0;
|
@@ -262,13 +262,13 @@ static VALUE grpc_rb_channel_init(int argc, VALUE *argv, VALUE self) {
|
|
262
262
|
}
|
263
263
|
|
264
264
|
typedef struct get_state_stack {
|
265
|
-
bg_watched_channel
|
265
|
+
bg_watched_channel* bg;
|
266
266
|
int try_to_connect;
|
267
267
|
int out;
|
268
268
|
} get_state_stack;
|
269
269
|
|
270
|
-
static void
|
271
|
-
get_state_stack
|
270
|
+
static void* get_state_without_gil(void* arg) {
|
271
|
+
get_state_stack* stack = (get_state_stack*)arg;
|
272
272
|
|
273
273
|
gpr_mu_lock(&global_connection_polling_mu);
|
274
274
|
GPR_ASSERT(abort_channel_polling || channel_polling_thread_started);
|
@@ -292,10 +292,10 @@ static void *get_state_without_gil(void *arg) {
|
|
292
292
|
constants defined in GRPC::Core::ConnectivityStates.
|
293
293
|
|
294
294
|
It also tries to connect if the chennel is idle in the second form. */
|
295
|
-
static VALUE grpc_rb_channel_get_connectivity_state(int argc, VALUE
|
295
|
+
static VALUE grpc_rb_channel_get_connectivity_state(int argc, VALUE* argv,
|
296
296
|
VALUE self) {
|
297
297
|
VALUE try_to_connect_param = Qfalse;
|
298
|
-
grpc_rb_channel
|
298
|
+
grpc_rb_channel* wrapper = NULL;
|
299
299
|
get_state_stack stack;
|
300
300
|
|
301
301
|
/* "01" == 0 mandatory args, 1 (try_to_connect) is optional */
|
@@ -315,22 +315,22 @@ static VALUE grpc_rb_channel_get_connectivity_state(int argc, VALUE *argv,
|
|
315
315
|
}
|
316
316
|
|
317
317
|
typedef struct watch_state_stack {
|
318
|
-
grpc_channel
|
318
|
+
grpc_channel* channel;
|
319
319
|
gpr_timespec deadline;
|
320
320
|
int last_state;
|
321
321
|
} watch_state_stack;
|
322
322
|
|
323
|
-
static void
|
324
|
-
watch_state_stack
|
325
|
-
watch_state_op
|
326
|
-
void
|
323
|
+
static void* wait_for_watch_state_op_complete_without_gvl(void* arg) {
|
324
|
+
watch_state_stack* stack = (watch_state_stack*)arg;
|
325
|
+
watch_state_op* op = NULL;
|
326
|
+
void* success = (void*)0;
|
327
327
|
|
328
328
|
gpr_mu_lock(&global_connection_polling_mu);
|
329
329
|
// its unsafe to do a "watch" after "channel polling abort" because the cq has
|
330
330
|
// been shut down.
|
331
331
|
if (abort_channel_polling) {
|
332
332
|
gpr_mu_unlock(&global_connection_polling_mu);
|
333
|
-
return (void
|
333
|
+
return (void*)0;
|
334
334
|
}
|
335
335
|
op = gpr_zalloc(sizeof(watch_state_op));
|
336
336
|
op->op_type = WATCH_STATE_API;
|
@@ -343,15 +343,15 @@ static void *wait_for_watch_state_op_complete_without_gvl(void *arg) {
|
|
343
343
|
gpr_inf_future(GPR_CLOCK_REALTIME));
|
344
344
|
}
|
345
345
|
if (op->op.api_callback_args.success) {
|
346
|
-
success = (void
|
346
|
+
success = (void*)1;
|
347
347
|
}
|
348
348
|
gpr_free(op);
|
349
349
|
gpr_mu_unlock(&global_connection_polling_mu);
|
350
350
|
|
351
351
|
return success;
|
352
352
|
}
|
353
|
-
static void wait_for_watch_state_op_complete_unblocking_func(void
|
354
|
-
bg_watched_channel
|
353
|
+
static void wait_for_watch_state_op_complete_unblocking_func(void* arg) {
|
354
|
+
bg_watched_channel* bg = (bg_watched_channel*)arg;
|
355
355
|
gpr_mu_lock(&global_connection_polling_mu);
|
356
356
|
if (!bg->channel_destroyed) {
|
357
357
|
grpc_channel_destroy(bg->channel);
|
@@ -370,9 +370,9 @@ static void wait_for_watch_state_op_complete_unblocking_func(void *arg) {
|
|
370
370
|
static VALUE grpc_rb_channel_watch_connectivity_state(VALUE self,
|
371
371
|
VALUE last_state,
|
372
372
|
VALUE deadline) {
|
373
|
-
grpc_rb_channel
|
373
|
+
grpc_rb_channel* wrapper = NULL;
|
374
374
|
watch_state_stack stack;
|
375
|
-
void
|
375
|
+
void* op_success = 0;
|
376
376
|
|
377
377
|
TypedData_Get_Struct(self, grpc_rb_channel, &grpc_channel_data_type, wrapper);
|
378
378
|
|
@@ -405,15 +405,15 @@ static VALUE grpc_rb_channel_create_call(VALUE self, VALUE parent, VALUE mask,
|
|
405
405
|
VALUE method, VALUE host,
|
406
406
|
VALUE deadline) {
|
407
407
|
VALUE res = Qnil;
|
408
|
-
grpc_rb_channel
|
409
|
-
grpc_call
|
410
|
-
grpc_call
|
411
|
-
grpc_completion_queue
|
408
|
+
grpc_rb_channel* wrapper = NULL;
|
409
|
+
grpc_call* call = NULL;
|
410
|
+
grpc_call* parent_call = NULL;
|
411
|
+
grpc_completion_queue* cq = NULL;
|
412
412
|
int flags = GRPC_PROPAGATE_DEFAULTS;
|
413
413
|
grpc_slice method_slice;
|
414
414
|
grpc_slice host_slice;
|
415
|
-
grpc_slice
|
416
|
-
char
|
415
|
+
grpc_slice* host_slice_ptr = NULL;
|
416
|
+
char* tmp_str = NULL;
|
417
417
|
|
418
418
|
if (host != Qnil) {
|
419
419
|
host_slice =
|
@@ -466,7 +466,7 @@ static VALUE grpc_rb_channel_create_call(VALUE self, VALUE parent, VALUE mask,
|
|
466
466
|
/* Note this is an API-level call; a wrapped channel's finalizer doesn't call
|
467
467
|
* this */
|
468
468
|
static VALUE grpc_rb_channel_destroy(VALUE self) {
|
469
|
-
grpc_rb_channel
|
469
|
+
grpc_rb_channel* wrapper = NULL;
|
470
470
|
|
471
471
|
TypedData_Get_Struct(self, grpc_rb_channel, &grpc_channel_data_type, wrapper);
|
472
472
|
if (wrapper->bg_wrapped != NULL) {
|
@@ -480,9 +480,9 @@ static VALUE grpc_rb_channel_destroy(VALUE self) {
|
|
480
480
|
|
481
481
|
/* Called to obtain the target that this channel accesses. */
|
482
482
|
static VALUE grpc_rb_channel_get_target(VALUE self) {
|
483
|
-
grpc_rb_channel
|
483
|
+
grpc_rb_channel* wrapper = NULL;
|
484
484
|
VALUE res = Qnil;
|
485
|
-
char
|
485
|
+
char* target = NULL;
|
486
486
|
|
487
487
|
TypedData_Get_Struct(self, grpc_rb_channel, &grpc_channel_data_type, wrapper);
|
488
488
|
target = grpc_channel_get_target(wrapper->bg_wrapped->channel);
|
@@ -493,8 +493,8 @@ static VALUE grpc_rb_channel_get_target(VALUE self) {
|
|
493
493
|
}
|
494
494
|
|
495
495
|
/* Needs to be called under global_connection_polling_mu */
|
496
|
-
static int bg_watched_channel_list_lookup(bg_watched_channel
|
497
|
-
bg_watched_channel
|
496
|
+
static int bg_watched_channel_list_lookup(bg_watched_channel* target) {
|
497
|
+
bg_watched_channel* cur = bg_watched_channel_list_head;
|
498
498
|
|
499
499
|
while (cur != NULL) {
|
500
500
|
if (cur == target) {
|
@@ -507,9 +507,9 @@ static int bg_watched_channel_list_lookup(bg_watched_channel *target) {
|
|
507
507
|
}
|
508
508
|
|
509
509
|
/* Needs to be called under global_connection_polling_mu */
|
510
|
-
static bg_watched_channel
|
511
|
-
grpc_channel
|
512
|
-
bg_watched_channel
|
510
|
+
static bg_watched_channel* bg_watched_channel_list_create_and_add(
|
511
|
+
grpc_channel* channel) {
|
512
|
+
bg_watched_channel* watched = gpr_zalloc(sizeof(bg_watched_channel));
|
513
513
|
|
514
514
|
watched->channel = channel;
|
515
515
|
watched->next = bg_watched_channel_list_head;
|
@@ -520,8 +520,8 @@ static bg_watched_channel *bg_watched_channel_list_create_and_add(
|
|
520
520
|
|
521
521
|
/* Needs to be called under global_connection_polling_mu */
|
522
522
|
static void bg_watched_channel_list_free_and_remove(
|
523
|
-
bg_watched_channel
|
524
|
-
bg_watched_channel
|
523
|
+
bg_watched_channel* target) {
|
524
|
+
bg_watched_channel* bg = NULL;
|
525
525
|
|
526
526
|
GPR_ASSERT(bg_watched_channel_list_lookup(target));
|
527
527
|
GPR_ASSERT(target->channel_destroyed && target->refcount == 0);
|
@@ -544,10 +544,10 @@ static void bg_watched_channel_list_free_and_remove(
|
|
544
544
|
|
545
545
|
/* Initialize a grpc_rb_channel's "protected grpc_channel" and try to push
|
546
546
|
* it onto the background thread for constant watches. */
|
547
|
-
static void
|
548
|
-
void
|
549
|
-
channel_init_try_register_stack
|
550
|
-
(channel_init_try_register_stack
|
547
|
+
static void* channel_init_try_register_connection_polling_without_gil(
|
548
|
+
void* arg) {
|
549
|
+
channel_init_try_register_stack* stack =
|
550
|
+
(channel_init_try_register_stack*)arg;
|
551
551
|
|
552
552
|
gpr_mu_lock(&global_connection_polling_mu);
|
553
553
|
stack->wrapper->bg_wrapped =
|
@@ -559,9 +559,9 @@ static void *channel_init_try_register_connection_polling_without_gil(
|
|
559
559
|
|
560
560
|
// Needs to be called under global_connection_poolling_mu
|
561
561
|
static void grpc_rb_channel_try_register_connection_polling(
|
562
|
-
bg_watched_channel
|
562
|
+
bg_watched_channel* bg) {
|
563
563
|
grpc_connectivity_state conn_state;
|
564
|
-
watch_state_op
|
564
|
+
watch_state_op* op = NULL;
|
565
565
|
|
566
566
|
GPR_ASSERT(channel_polling_thread_started || abort_channel_polling);
|
567
567
|
|
@@ -597,10 +597,10 @@ static void grpc_rb_channel_try_register_connection_polling(
|
|
597
597
|
// indicates process shutdown.
|
598
598
|
// In the worst case, this stops polling channel connectivity
|
599
599
|
// early and falls back to current behavior.
|
600
|
-
static void
|
600
|
+
static void* run_poll_channels_loop_no_gil(void* arg) {
|
601
601
|
grpc_event event;
|
602
|
-
watch_state_op
|
603
|
-
bg_watched_channel
|
602
|
+
watch_state_op* op = NULL;
|
603
|
+
bg_watched_channel* bg = NULL;
|
604
604
|
(void)arg;
|
605
605
|
gpr_log(GPR_DEBUG, "GRPC_RUBY: run_poll_channels_loop_no_gil - begin");
|
606
606
|
|
@@ -618,15 +618,15 @@ static void *run_poll_channels_loop_no_gil(void *arg) {
|
|
618
618
|
}
|
619
619
|
gpr_mu_lock(&global_connection_polling_mu);
|
620
620
|
if (event.type == GRPC_OP_COMPLETE) {
|
621
|
-
op = (watch_state_op
|
621
|
+
op = (watch_state_op*)event.tag;
|
622
622
|
if (op->op_type == CONTINUOUS_WATCH) {
|
623
|
-
bg = (bg_watched_channel
|
623
|
+
bg = (bg_watched_channel*)op->op.continuous_watch_callback_args.bg;
|
624
624
|
bg->refcount--;
|
625
625
|
grpc_rb_channel_try_register_connection_polling(bg);
|
626
626
|
gpr_free(op);
|
627
627
|
} else if (op->op_type == WATCH_STATE_API) {
|
628
628
|
grpc_rb_channel_watch_connection_state_op_complete(
|
629
|
-
(watch_state_op
|
629
|
+
(watch_state_op*)event.tag, event.success);
|
630
630
|
} else {
|
631
631
|
GPR_ASSERT(0);
|
632
632
|
}
|
@@ -641,8 +641,8 @@ static void *run_poll_channels_loop_no_gil(void *arg) {
|
|
641
641
|
}
|
642
642
|
|
643
643
|
// Notify the channel polling loop to cleanup and shutdown.
|
644
|
-
static void run_poll_channels_loop_unblocking_func(void
|
645
|
-
bg_watched_channel
|
644
|
+
static void run_poll_channels_loop_unblocking_func(void* arg) {
|
645
|
+
bg_watched_channel* bg = NULL;
|
646
646
|
(void)arg;
|
647
647
|
|
648
648
|
gpr_mu_lock(&global_connection_polling_mu);
|
@@ -686,8 +686,8 @@ static VALUE run_poll_channels_loop(VALUE arg) {
|
|
686
686
|
return Qnil;
|
687
687
|
}
|
688
688
|
|
689
|
-
static void
|
690
|
-
int
|
689
|
+
static void* wait_until_channel_polling_thread_started_no_gil(void* arg) {
|
690
|
+
int* stop_waiting = (int*)arg;
|
691
691
|
gpr_log(GPR_DEBUG, "GRPC_RUBY: wait for channel polling thread to start");
|
692
692
|
gpr_mu_lock(&global_connection_polling_mu);
|
693
693
|
while (!channel_polling_thread_started && !abort_channel_polling &&
|
@@ -701,8 +701,8 @@ static void *wait_until_channel_polling_thread_started_no_gil(void *arg) {
|
|
701
701
|
}
|
702
702
|
|
703
703
|
static void wait_until_channel_polling_thread_started_unblocking_func(
|
704
|
-
void
|
705
|
-
int
|
704
|
+
void* arg) {
|
705
|
+
int* stop_waiting = (int*)arg;
|
706
706
|
gpr_mu_lock(&global_connection_polling_mu);
|
707
707
|
gpr_log(GPR_DEBUG,
|
708
708
|
"GRPC_RUBY: interrupt wait for channel polling thread to start");
|
@@ -711,7 +711,7 @@ static void wait_until_channel_polling_thread_started_unblocking_func(
|
|
711
711
|
gpr_mu_unlock(&global_connection_polling_mu);
|
712
712
|
}
|
713
713
|
|
714
|
-
static void
|
714
|
+
static void* set_abort_channel_polling_without_gil(void* arg) {
|
715
715
|
(void)arg;
|
716
716
|
gpr_mu_lock(&global_connection_polling_mu);
|
717
717
|
abort_channel_polling = 1;
|
@@ -822,8 +822,8 @@ void Init_grpc_channel() {
|
|
822
822
|
}
|
823
823
|
|
824
824
|
/* Gets the wrapped channel from the ruby wrapper */
|
825
|
-
grpc_channel
|
826
|
-
grpc_rb_channel
|
825
|
+
grpc_channel* grpc_rb_get_wrapped_channel(VALUE v) {
|
826
|
+
grpc_rb_channel* wrapper = NULL;
|
827
827
|
TypedData_Get_Struct(v, grpc_rb_channel, &grpc_channel_data_type, wrapper);
|
828
828
|
return wrapper->bg_wrapped->channel;
|
829
829
|
}
|
@@ -35,7 +35,7 @@
|
|
35
35
|
grpc_channel_credentials. */
|
36
36
|
static VALUE grpc_rb_cChannelCredentials = Qnil;
|
37
37
|
|
38
|
-
static char
|
38
|
+
static char* pem_root_certs = NULL;
|
39
39
|
|
40
40
|
/* grpc_rb_channel_credentials wraps a grpc_channel_credentials. It provides a
|
41
41
|
* mark object that is used to hold references to any objects used to create
|
@@ -45,16 +45,16 @@ typedef struct grpc_rb_channel_credentials {
|
|
45
45
|
VALUE mark;
|
46
46
|
|
47
47
|
/* The actual credentials */
|
48
|
-
grpc_channel_credentials
|
48
|
+
grpc_channel_credentials* wrapped;
|
49
49
|
} grpc_rb_channel_credentials;
|
50
50
|
|
51
51
|
/* Destroys the credentials instances. */
|
52
|
-
static void grpc_rb_channel_credentials_free(void
|
53
|
-
grpc_rb_channel_credentials
|
52
|
+
static void grpc_rb_channel_credentials_free(void* p) {
|
53
|
+
grpc_rb_channel_credentials* wrapper = NULL;
|
54
54
|
if (p == NULL) {
|
55
55
|
return;
|
56
56
|
};
|
57
|
-
wrapper = (grpc_rb_channel_credentials
|
57
|
+
wrapper = (grpc_rb_channel_credentials*)p;
|
58
58
|
grpc_channel_credentials_release(wrapper->wrapped);
|
59
59
|
wrapper->wrapped = NULL;
|
60
60
|
|
@@ -62,12 +62,12 @@ static void grpc_rb_channel_credentials_free(void *p) {
|
|
62
62
|
}
|
63
63
|
|
64
64
|
/* Protects the mark object from GC */
|
65
|
-
static void grpc_rb_channel_credentials_mark(void
|
66
|
-
grpc_rb_channel_credentials
|
65
|
+
static void grpc_rb_channel_credentials_mark(void* p) {
|
66
|
+
grpc_rb_channel_credentials* wrapper = NULL;
|
67
67
|
if (p == NULL) {
|
68
68
|
return;
|
69
69
|
}
|
70
|
-
wrapper = (grpc_rb_channel_credentials
|
70
|
+
wrapper = (grpc_rb_channel_credentials*)p;
|
71
71
|
|
72
72
|
if (wrapper->mark != Qnil) {
|
73
73
|
rb_gc_mark(wrapper->mark);
|
@@ -90,7 +90,7 @@ static rb_data_type_t grpc_rb_channel_credentials_data_type = {
|
|
90
90
|
/* Allocates ChannelCredential instances.
|
91
91
|
Provides safe initial defaults for the instance fields. */
|
92
92
|
static VALUE grpc_rb_channel_credentials_alloc(VALUE cls) {
|
93
|
-
grpc_rb_channel_credentials
|
93
|
+
grpc_rb_channel_credentials* wrapper = ALLOC(grpc_rb_channel_credentials);
|
94
94
|
wrapper->wrapped = NULL;
|
95
95
|
wrapper->mark = Qnil;
|
96
96
|
return TypedData_Wrap_Struct(cls, &grpc_rb_channel_credentials_data_type,
|
@@ -100,10 +100,10 @@ static VALUE grpc_rb_channel_credentials_alloc(VALUE cls) {
|
|
100
100
|
/* Creates a wrapping object for a given channel credentials. This should only
|
101
101
|
* be called with grpc_channel_credentials objects that are not already
|
102
102
|
* associated with any Ruby object. */
|
103
|
-
VALUE grpc_rb_wrap_channel_credentials(grpc_channel_credentials
|
103
|
+
VALUE grpc_rb_wrap_channel_credentials(grpc_channel_credentials* c,
|
104
104
|
VALUE mark) {
|
105
105
|
VALUE rb_wrapper;
|
106
|
-
grpc_rb_channel_credentials
|
106
|
+
grpc_rb_channel_credentials* wrapper;
|
107
107
|
if (c == NULL) {
|
108
108
|
return Qnil;
|
109
109
|
}
|
@@ -136,15 +136,15 @@ static ID id_pem_cert_chain;
|
|
136
136
|
pem_private_key: (optional) PEM encoding of the client's private key
|
137
137
|
pem_cert_chain: (optional) PEM encoding of the client's cert chain
|
138
138
|
Initializes Credential instances. */
|
139
|
-
static VALUE grpc_rb_channel_credentials_init(int argc, VALUE
|
139
|
+
static VALUE grpc_rb_channel_credentials_init(int argc, VALUE* argv,
|
140
140
|
VALUE self) {
|
141
141
|
VALUE pem_root_certs = Qnil;
|
142
142
|
VALUE pem_private_key = Qnil;
|
143
143
|
VALUE pem_cert_chain = Qnil;
|
144
|
-
grpc_rb_channel_credentials
|
145
|
-
grpc_channel_credentials
|
144
|
+
grpc_rb_channel_credentials* wrapper = NULL;
|
145
|
+
grpc_channel_credentials* creds = NULL;
|
146
146
|
grpc_ssl_pem_key_cert_pair key_cert_pair;
|
147
|
-
const char
|
147
|
+
const char* pem_root_certs_cstr = NULL;
|
148
148
|
MEMZERO(&key_cert_pair, grpc_ssl_pem_key_cert_pair, 1);
|
149
149
|
|
150
150
|
grpc_ruby_once_init();
|
@@ -180,11 +180,11 @@ static VALUE grpc_rb_channel_credentials_init(int argc, VALUE *argv,
|
|
180
180
|
return self;
|
181
181
|
}
|
182
182
|
|
183
|
-
static VALUE grpc_rb_channel_credentials_compose(int argc, VALUE
|
183
|
+
static VALUE grpc_rb_channel_credentials_compose(int argc, VALUE* argv,
|
184
184
|
VALUE self) {
|
185
|
-
grpc_channel_credentials
|
186
|
-
grpc_call_credentials
|
187
|
-
grpc_channel_credentials
|
185
|
+
grpc_channel_credentials* creds;
|
186
|
+
grpc_call_credentials* other;
|
187
|
+
grpc_channel_credentials* prev = NULL;
|
188
188
|
VALUE mark;
|
189
189
|
if (argc == 0) {
|
190
190
|
return self;
|
@@ -210,7 +210,7 @@ static VALUE grpc_rb_channel_credentials_compose(int argc, VALUE *argv,
|
|
210
210
|
}
|
211
211
|
|
212
212
|
static grpc_ssl_roots_override_result get_ssl_roots_override(
|
213
|
-
char
|
213
|
+
char** pem_root_certs_ptr) {
|
214
214
|
*pem_root_certs_ptr = pem_root_certs;
|
215
215
|
if (pem_root_certs == NULL) {
|
216
216
|
return GRPC_SSL_ROOTS_OVERRIDE_FAIL;
|
@@ -220,7 +220,7 @@ static grpc_ssl_roots_override_result get_ssl_roots_override(
|
|
220
220
|
}
|
221
221
|
|
222
222
|
static VALUE grpc_rb_set_default_roots_pem(VALUE self, VALUE roots) {
|
223
|
-
char
|
223
|
+
char* roots_ptr = StringValueCStr(roots);
|
224
224
|
size_t length = strlen(roots_ptr);
|
225
225
|
(void)self;
|
226
226
|
pem_root_certs = gpr_malloc((length + 1) * sizeof(char));
|
@@ -255,8 +255,8 @@ void Init_grpc_channel_credentials() {
|
|
255
255
|
}
|
256
256
|
|
257
257
|
/* Gets the wrapped grpc_channel_credentials from the ruby wrapper */
|
258
|
-
grpc_channel_credentials
|
259
|
-
grpc_rb_channel_credentials
|
258
|
+
grpc_channel_credentials* grpc_rb_get_wrapped_channel_credentials(VALUE v) {
|
259
|
+
grpc_rb_channel_credentials* wrapper = NULL;
|
260
260
|
TypedData_Get_Struct(v, grpc_rb_channel_credentials,
|
261
261
|
&grpc_rb_channel_credentials_data_type, wrapper);
|
262
262
|
return wrapper->wrapped;
|