grpc 1.3.4-universal-darwin → 1.4.0-universal-darwin
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/src/ruby/ext/grpc/extconf.rb +2 -1
- data/src/ruby/ext/grpc/rb_byte_buffer.c +8 -6
- data/src/ruby/ext/grpc/rb_call.c +56 -48
- data/src/ruby/ext/grpc/rb_call.h +3 -4
- data/src/ruby/ext/grpc/rb_call_credentials.c +23 -22
- data/src/ruby/ext/grpc/rb_channel.c +2 -3
- data/src/ruby/ext/grpc/rb_channel_args.c +11 -9
- data/src/ruby/ext/grpc/rb_channel_credentials.c +16 -12
- data/src/ruby/ext/grpc/rb_completion_queue.c +7 -9
- data/src/ruby/ext/grpc/rb_compression_options.c +7 -6
- data/src/ruby/ext/grpc/rb_event_thread.c +10 -12
- data/src/ruby/ext/grpc/rb_event_thread.h +1 -2
- data/src/ruby/ext/grpc/rb_grpc.c +11 -15
- data/src/ruby/ext/grpc/rb_grpc.h +2 -2
- data/src/ruby/ext/grpc/rb_grpc_imports.generated.c +16 -6
- data/src/ruby/ext/grpc/rb_grpc_imports.generated.h +25 -10
- data/src/ruby/ext/grpc/rb_server.c +26 -28
- data/src/ruby/lib/grpc/2.0/grpc_c.bundle +0 -0
- data/src/ruby/lib/grpc/2.1/grpc_c.bundle +0 -0
- data/src/ruby/lib/grpc/2.2/grpc_c.bundle +0 -0
- data/src/ruby/lib/grpc/2.3/grpc_c.bundle +0 -0
- data/src/ruby/lib/grpc/2.4/grpc_c.bundle +0 -0
- data/src/ruby/lib/grpc/grpc.rb +1 -1
- data/src/ruby/lib/grpc/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 1de90894ee86145d82ba179bc4a700850fbeff7f
|
4
|
+
data.tar.gz: 0f47250c774601a753434008104410886046a98a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 888d444223339a02535448330055448deb7acae6c24ce7dbd7b892ef0924c95fa7c927f3fe0f3e3d3d0f37e09408b7984a2b504c3a6c38578ef148c4d53ebedc
|
7
|
+
data.tar.gz: 31e9d15bd2ba7123359632326c298c3d4208c9717220c4578034aeb3e67c348951eb3e45a7ebb8966f6b45e634112bafe933022f4e93feb508dba11ff3bb0f53
|
@@ -65,6 +65,7 @@ ENV['MACOSX_DEPLOYMENT_TARGET'] = '10.7'
|
|
65
65
|
|
66
66
|
ENV['AR'] = RbConfig::CONFIG['AR'] + ' rcs'
|
67
67
|
ENV['CC'] = RbConfig::CONFIG['CC']
|
68
|
+
ENV['CXX'] = RbConfig::CONFIG['CXX']
|
68
69
|
ENV['LD'] = ENV['CC']
|
69
70
|
|
70
71
|
ENV['AR'] = 'libtool -o' if RUBY_PLATFORM =~ /darwin/
|
@@ -84,7 +85,7 @@ unless windows
|
|
84
85
|
puts 'Building internal gRPC into ' + grpc_lib_dir
|
85
86
|
nproc = 4
|
86
87
|
nproc = Etc.nprocessors * 2 if Etc.respond_to? :nprocessors
|
87
|
-
system("make -j#{nproc} -C #{grpc_root} #{grpc_lib_dir}/libgrpc.a CONFIG=#{grpc_config}")
|
88
|
+
system("make -j#{nproc} -C #{grpc_root} #{grpc_lib_dir}/libgrpc.a CONFIG=#{grpc_config} Q=")
|
88
89
|
exit 1 unless $? == 0
|
89
90
|
end
|
90
91
|
|
@@ -33,15 +33,15 @@
|
|
33
33
|
|
34
34
|
#include <ruby/ruby.h>
|
35
35
|
|
36
|
-
#include "rb_grpc_imports.generated.h"
|
37
36
|
#include "rb_byte_buffer.h"
|
37
|
+
#include "rb_grpc_imports.generated.h"
|
38
38
|
|
39
|
-
#include <grpc/grpc.h>
|
40
39
|
#include <grpc/byte_buffer_reader.h>
|
40
|
+
#include <grpc/grpc.h>
|
41
41
|
#include <grpc/slice.h>
|
42
42
|
#include "rb_grpc.h"
|
43
43
|
|
44
|
-
grpc_byte_buffer*
|
44
|
+
grpc_byte_buffer *grpc_rb_s_to_byte_buffer(char *string, size_t length) {
|
45
45
|
grpc_slice slice = grpc_slice_from_copied_buffer(string, length);
|
46
46
|
grpc_byte_buffer *buffer = grpc_raw_byte_buffer_create(&slice, 1);
|
47
47
|
grpc_slice_unref(slice);
|
@@ -61,7 +61,7 @@ VALUE grpc_rb_byte_buffer_to_s(grpc_byte_buffer *buffer) {
|
|
61
61
|
return Qnil;
|
62
62
|
}
|
63
63
|
while (grpc_byte_buffer_reader_next(&reader, &next) != 0) {
|
64
|
-
rb_str_cat(rb_string, (const char *)
|
64
|
+
rb_str_cat(rb_string, (const char *)GRPC_SLICE_START_PTR(next),
|
65
65
|
GRPC_SLICE_LENGTH(next));
|
66
66
|
grpc_slice_unref(next);
|
67
67
|
}
|
@@ -71,7 +71,9 @@ VALUE grpc_rb_byte_buffer_to_s(grpc_byte_buffer *buffer) {
|
|
71
71
|
|
72
72
|
VALUE grpc_rb_slice_to_ruby_string(grpc_slice slice) {
|
73
73
|
if (GRPC_SLICE_START_PTR(slice) == NULL) {
|
74
|
-
rb_raise(rb_eRuntimeError,
|
74
|
+
rb_raise(rb_eRuntimeError,
|
75
|
+
"attempt to convert uninitialized grpc_slice to ruby string");
|
75
76
|
}
|
76
|
-
return rb_str_new((char*)GRPC_SLICE_START_PTR(slice),
|
77
|
+
return rb_str_new((char *)GRPC_SLICE_START_PTR(slice),
|
78
|
+
GRPC_SLICE_LENGTH(slice));
|
77
79
|
}
|
data/src/ruby/ext/grpc/rb_call.c
CHANGED
@@ -33,12 +33,12 @@
|
|
33
33
|
|
34
34
|
#include <ruby/ruby.h>
|
35
35
|
|
36
|
-
#include "rb_grpc_imports.generated.h"
|
37
36
|
#include "rb_call.h"
|
37
|
+
#include "rb_grpc_imports.generated.h"
|
38
38
|
|
39
39
|
#include <grpc/grpc.h>
|
40
|
-
#include <grpc/support/alloc.h>
|
41
40
|
#include <grpc/impl/codegen/compression_types.h>
|
41
|
+
#include <grpc/support/alloc.h>
|
42
42
|
|
43
43
|
#include "rb_byte_buffer.h"
|
44
44
|
#include "rb_call_credentials.h"
|
@@ -101,7 +101,7 @@ typedef struct grpc_rb_call {
|
|
101
101
|
static void destroy_call(grpc_rb_call *call) {
|
102
102
|
/* Ensure that we only try to destroy the call once */
|
103
103
|
if (call->wrapped != NULL) {
|
104
|
-
|
104
|
+
grpc_call_unref(call->wrapped);
|
105
105
|
call->wrapped = NULL;
|
106
106
|
grpc_rb_completion_queue_destroy(call->queue);
|
107
107
|
call->queue = NULL;
|
@@ -113,7 +113,7 @@ static void grpc_rb_call_destroy(void *p) {
|
|
113
113
|
if (p == NULL) {
|
114
114
|
return;
|
115
115
|
}
|
116
|
-
destroy_call((grpc_rb_call*)p);
|
116
|
+
destroy_call((grpc_rb_call *)p);
|
117
117
|
}
|
118
118
|
|
119
119
|
static size_t md_ary_datasize(const void *p) {
|
@@ -130,7 +130,9 @@ static size_t md_ary_datasize(const void *p) {
|
|
130
130
|
|
131
131
|
static const rb_data_type_t grpc_rb_md_ary_data_type = {
|
132
132
|
"grpc_metadata_array",
|
133
|
-
{GRPC_RB_GC_NOT_MARKED,
|
133
|
+
{GRPC_RB_GC_NOT_MARKED,
|
134
|
+
GRPC_RB_GC_DONT_FREE,
|
135
|
+
md_ary_datasize,
|
134
136
|
{NULL, NULL}},
|
135
137
|
NULL,
|
136
138
|
NULL,
|
@@ -140,19 +142,20 @@ static const rb_data_type_t grpc_rb_md_ary_data_type = {
|
|
140
142
|
* touches a hash object.
|
141
143
|
* TODO(yugui) Directly use st_table and call the free function earlier?
|
142
144
|
*/
|
143
|
-
|
145
|
+
0,
|
144
146
|
#endif
|
145
147
|
};
|
146
148
|
|
147
149
|
/* Describes grpc_call struct for RTypedData */
|
148
|
-
static const rb_data_type_t grpc_call_data_type = {
|
149
|
-
|
150
|
-
|
151
|
-
|
152
|
-
|
153
|
-
|
150
|
+
static const rb_data_type_t grpc_call_data_type = {"grpc_call",
|
151
|
+
{GRPC_RB_GC_NOT_MARKED,
|
152
|
+
grpc_rb_call_destroy,
|
153
|
+
GRPC_RB_MEMSIZE_UNAVAILABLE,
|
154
|
+
{NULL, NULL}},
|
155
|
+
NULL,
|
156
|
+
NULL,
|
154
157
|
#ifdef RUBY_TYPED_FREE_IMMEDIATELY
|
155
|
-
|
158
|
+
RUBY_TYPED_FREE_IMMEDIATELY
|
156
159
|
#endif
|
157
160
|
};
|
158
161
|
|
@@ -175,7 +178,7 @@ static VALUE grpc_rb_call_cancel(VALUE self) {
|
|
175
178
|
grpc_rb_call *call = NULL;
|
176
179
|
grpc_call_error err;
|
177
180
|
if (RTYPEDDATA_DATA(self) == NULL) {
|
178
|
-
//This call has been closed
|
181
|
+
// This call has been closed
|
179
182
|
return Qnil;
|
180
183
|
}
|
181
184
|
|
@@ -196,7 +199,7 @@ static VALUE grpc_rb_call_cancel(VALUE self) {
|
|
196
199
|
static VALUE grpc_rb_call_close(VALUE self) {
|
197
200
|
grpc_rb_call *call = NULL;
|
198
201
|
TypedData_Get_Struct(self, grpc_rb_call, &grpc_call_data_type, call);
|
199
|
-
if(call != NULL) {
|
202
|
+
if (call != NULL) {
|
200
203
|
destroy_call(call);
|
201
204
|
RTYPEDDATA_DATA(self) = NULL;
|
202
205
|
}
|
@@ -238,8 +241,8 @@ static VALUE grpc_rb_call_get_peer_cert(VALUE self) {
|
|
238
241
|
}
|
239
242
|
|
240
243
|
{
|
241
|
-
grpc_auth_property_iterator it =
|
242
|
-
|
244
|
+
grpc_auth_property_iterator it = grpc_auth_context_find_properties_by_name(
|
245
|
+
ctx, GRPC_X509_PEM_CERT_PROPERTY_NAME);
|
243
246
|
const grpc_auth_property *prop = grpc_auth_property_iterator_next(&it);
|
244
247
|
if (prop == NULL) {
|
245
248
|
return Qnil;
|
@@ -388,21 +391,22 @@ static int grpc_rb_md_ary_fill_hash_cb(VALUE key, VALUE val, VALUE md_ary_obj) {
|
|
388
391
|
long i;
|
389
392
|
grpc_slice key_slice;
|
390
393
|
grpc_slice value_slice;
|
391
|
-
char*
|
394
|
+
char *tmp_str;
|
392
395
|
|
393
396
|
if (TYPE(key) == T_SYMBOL) {
|
394
397
|
key_slice = grpc_slice_from_static_string(rb_id2name(SYM2ID(key)));
|
395
398
|
} else if (TYPE(key) == T_STRING) {
|
396
|
-
key_slice =
|
399
|
+
key_slice =
|
400
|
+
grpc_slice_from_copied_buffer(RSTRING_PTR(key), RSTRING_LEN(key));
|
397
401
|
} else {
|
398
|
-
rb_raise(rb_eTypeError,
|
402
|
+
rb_raise(rb_eTypeError,
|
403
|
+
"grpc_rb_md_ary_fill_hash_cb: bad type for key parameter");
|
399
404
|
}
|
400
405
|
|
401
406
|
if (!grpc_header_key_is_legal(key_slice)) {
|
402
407
|
tmp_str = grpc_slice_to_c_string(key_slice);
|
403
408
|
rb_raise(rb_eArgError,
|
404
|
-
"'%s' is an invalid header key, must match [a-z0-9-_.]+",
|
405
|
-
tmp_str);
|
409
|
+
"'%s' is an invalid header key, must match [a-z0-9-_.]+", tmp_str);
|
406
410
|
return ST_STOP;
|
407
411
|
}
|
408
412
|
|
@@ -414,13 +418,14 @@ static int grpc_rb_md_ary_fill_hash_cb(VALUE key, VALUE val, VALUE md_ary_obj) {
|
|
414
418
|
array_length = RARRAY_LEN(val);
|
415
419
|
/* If the value is an array, add capacity for each value in the array */
|
416
420
|
for (i = 0; i < array_length; i++) {
|
417
|
-
value_slice = grpc_slice_from_copied_buffer(
|
421
|
+
value_slice = grpc_slice_from_copied_buffer(
|
422
|
+
RSTRING_PTR(rb_ary_entry(val, i)), RSTRING_LEN(rb_ary_entry(val, i)));
|
418
423
|
if (!grpc_is_binary_header(key_slice) &&
|
419
424
|
!grpc_header_nonbin_value_is_legal(value_slice)) {
|
420
425
|
// The value has invalid characters
|
421
426
|
tmp_str = grpc_slice_to_c_string(value_slice);
|
422
|
-
rb_raise(rb_eArgError,
|
423
|
-
|
427
|
+
rb_raise(rb_eArgError, "Header value '%s' has invalid characters",
|
428
|
+
tmp_str);
|
424
429
|
return ST_STOP;
|
425
430
|
}
|
426
431
|
md_ary->metadata[md_ary->count].key = key_slice;
|
@@ -428,21 +433,21 @@ static int grpc_rb_md_ary_fill_hash_cb(VALUE key, VALUE val, VALUE md_ary_obj) {
|
|
428
433
|
md_ary->count += 1;
|
429
434
|
}
|
430
435
|
} else if (TYPE(val) == T_STRING) {
|
431
|
-
value_slice =
|
436
|
+
value_slice =
|
437
|
+
grpc_slice_from_copied_buffer(RSTRING_PTR(val), RSTRING_LEN(val));
|
432
438
|
if (!grpc_is_binary_header(key_slice) &&
|
433
439
|
!grpc_header_nonbin_value_is_legal(value_slice)) {
|
434
440
|
// The value has invalid characters
|
435
441
|
tmp_str = grpc_slice_to_c_string(value_slice);
|
436
|
-
rb_raise(rb_eArgError,
|
437
|
-
|
442
|
+
rb_raise(rb_eArgError, "Header value '%s' has invalid characters",
|
443
|
+
tmp_str);
|
438
444
|
return ST_STOP;
|
439
445
|
}
|
440
446
|
md_ary->metadata[md_ary->count].key = key_slice;
|
441
447
|
md_ary->metadata[md_ary->count].value = value_slice;
|
442
448
|
md_ary->count += 1;
|
443
449
|
} else {
|
444
|
-
rb_raise(rb_eArgError,
|
445
|
-
"Header values must be of type string or array");
|
450
|
+
rb_raise(rb_eArgError, "Header values must be of type string or array");
|
446
451
|
return ST_STOP;
|
447
452
|
}
|
448
453
|
|
@@ -474,8 +479,7 @@ static int grpc_rb_md_ary_capacity_hash_cb(VALUE key, VALUE val,
|
|
474
479
|
/* grpc_rb_md_ary_convert converts a ruby metadata hash into
|
475
480
|
a grpc_metadata_array.
|
476
481
|
*/
|
477
|
-
void grpc_rb_md_ary_convert(VALUE md_ary_hash,
|
478
|
-
grpc_metadata_array *md_ary) {
|
482
|
+
void grpc_rb_md_ary_convert(VALUE md_ary_hash, grpc_metadata_array *md_ary) {
|
479
483
|
VALUE md_ary_obj = Qnil;
|
480
484
|
if (md_ary_hash == Qnil) {
|
481
485
|
return; /* Do nothing if the expected has value is nil */
|
@@ -511,12 +515,14 @@ VALUE grpc_rb_md_ary_to_h(grpc_metadata_array *md_ary) {
|
|
511
515
|
rb_hash_aset(result, key, value);
|
512
516
|
} else if (TYPE(value) == T_ARRAY) {
|
513
517
|
/* Add the string to the returned array */
|
514
|
-
rb_ary_push(value,
|
518
|
+
rb_ary_push(value,
|
519
|
+
grpc_rb_slice_to_ruby_string(md_ary->metadata[i].value));
|
515
520
|
} else {
|
516
521
|
/* Add the current value with this key and the new one to an array */
|
517
522
|
new_ary = rb_ary_new();
|
518
523
|
rb_ary_push(new_ary, value);
|
519
|
-
rb_ary_push(new_ary,
|
524
|
+
rb_ary_push(new_ary,
|
525
|
+
grpc_rb_slice_to_ruby_string(md_ary->metadata[i].value));
|
520
526
|
rb_hash_aset(result, key, new_ary);
|
521
527
|
}
|
522
528
|
}
|
@@ -556,10 +562,9 @@ static int grpc_rb_call_check_op_keys_hash_cb(VALUE key, VALUE val,
|
|
556
562
|
/* grpc_rb_op_update_status_from_server adds the values in a ruby status
|
557
563
|
struct to the 'send_status_from_server' portion of an op.
|
558
564
|
*/
|
559
|
-
static void grpc_rb_op_update_status_from_server(
|
560
|
-
|
561
|
-
|
562
|
-
VALUE status) {
|
565
|
+
static void grpc_rb_op_update_status_from_server(
|
566
|
+
grpc_op *op, grpc_metadata_array *md_ary, grpc_slice *send_status_details,
|
567
|
+
VALUE status) {
|
563
568
|
VALUE code = rb_struct_aref(status, sym_code);
|
564
569
|
VALUE details = rb_struct_aref(status, sym_details);
|
565
570
|
VALUE metadata_hash = rb_struct_aref(status, sym_metadata);
|
@@ -576,7 +581,8 @@ static void grpc_rb_op_update_status_from_server(grpc_op *op,
|
|
576
581
|
return;
|
577
582
|
}
|
578
583
|
|
579
|
-
*send_status_details =
|
584
|
+
*send_status_details =
|
585
|
+
grpc_slice_from_copied_buffer(RSTRING_PTR(details), RSTRING_LEN(details));
|
580
586
|
|
581
587
|
op->data.send_status_from_server.status = NUM2INT(code);
|
582
588
|
op->data.send_status_from_server.status_details = send_status_details;
|
@@ -687,7 +693,8 @@ static void grpc_run_batch_stack_fill_ops(run_batch_stack *st, VALUE ops_hash) {
|
|
687
693
|
/* N.B. later there is no need to explicitly delete the metadata keys
|
688
694
|
* and values, they are references to data in ruby objects. */
|
689
695
|
grpc_rb_op_update_status_from_server(
|
690
|
-
&st->ops[st->op_num], &st->send_trailing_metadata,
|
696
|
+
&st->ops[st->op_num], &st->send_trailing_metadata,
|
697
|
+
&st->send_status_details, this_value);
|
691
698
|
break;
|
692
699
|
case GRPC_OP_RECV_INITIAL_METADATA:
|
693
700
|
st->ops[st->op_num].data.recv_initial_metadata.recv_initial_metadata =
|
@@ -749,12 +756,12 @@ static VALUE grpc_run_batch_stack_build_result(run_batch_stack *st) {
|
|
749
756
|
case GRPC_OP_RECV_STATUS_ON_CLIENT:
|
750
757
|
rb_struct_aset(
|
751
758
|
result, sym_status,
|
752
|
-
rb_struct_new(
|
753
|
-
|
754
|
-
|
755
|
-
|
756
|
-
|
757
|
-
|
759
|
+
rb_struct_new(
|
760
|
+
grpc_rb_sStatus, UINT2NUM(st->recv_status),
|
761
|
+
(GRPC_SLICE_START_PTR(st->recv_status_details) == NULL
|
762
|
+
? Qnil
|
763
|
+
: grpc_rb_slice_to_ruby_string(st->recv_status_details)),
|
764
|
+
grpc_rb_md_ary_to_h(&st->recv_trailing_metadata), NULL));
|
758
765
|
break;
|
759
766
|
case GRPC_OP_RECV_CLOSE_ON_SERVER:
|
760
767
|
rb_struct_aset(result, sym_send_close, Qtrue);
|
@@ -791,7 +798,7 @@ static VALUE grpc_rb_call_run_batch(VALUE self, VALUE ops_hash) {
|
|
791
798
|
VALUE result = Qnil;
|
792
799
|
VALUE rb_write_flag = rb_ivar_get(self, id_write_flag);
|
793
800
|
unsigned write_flag = 0;
|
794
|
-
void *tag = (void*)&st;
|
801
|
+
void *tag = (void *)&st;
|
795
802
|
|
796
803
|
if (RTYPEDDATA_DATA(self) == NULL) {
|
797
804
|
rb_raise(grpc_rb_eCallError, "Cannot run batch on closed call");
|
@@ -919,7 +926,8 @@ static void Init_grpc_op_codes() {
|
|
919
926
|
}
|
920
927
|
|
921
928
|
static void Init_grpc_metadata_keys() {
|
922
|
-
VALUE grpc_rb_mMetadataKeys =
|
929
|
+
VALUE grpc_rb_mMetadataKeys =
|
930
|
+
rb_define_module_under(grpc_rb_mGrpcCore, "MetadataKeys");
|
923
931
|
rb_define_const(grpc_rb_mMetadataKeys, "COMPRESSION_REQUEST_ALGORITHM",
|
924
932
|
rb_str_new2(GRPC_COMPRESSION_REQUEST_ALGORITHM_MD_KEY));
|
925
933
|
}
|
data/src/ruby/ext/grpc/rb_call.h
CHANGED
@@ -39,13 +39,13 @@
|
|
39
39
|
#include <grpc/grpc.h>
|
40
40
|
|
41
41
|
/* Gets the wrapped call from a VALUE. */
|
42
|
-
grpc_call*
|
42
|
+
grpc_call *grpc_rb_get_wrapped_call(VALUE v);
|
43
43
|
|
44
44
|
/* Gets the VALUE corresponding to given grpc_call. */
|
45
45
|
VALUE grpc_rb_wrap_call(grpc_call *c, grpc_completion_queue *q);
|
46
46
|
|
47
47
|
/* Provides the details of an call error */
|
48
|
-
const char*
|
48
|
+
const char *grpc_call_error_detail_of(grpc_call_error err);
|
49
49
|
|
50
50
|
/* Converts a metadata array to a hash. */
|
51
51
|
VALUE grpc_rb_md_ary_to_h(grpc_metadata_array *md_ary);
|
@@ -53,8 +53,7 @@ VALUE grpc_rb_md_ary_to_h(grpc_metadata_array *md_ary);
|
|
53
53
|
/* grpc_rb_md_ary_convert converts a ruby metadata hash into
|
54
54
|
a grpc_metadata_array.
|
55
55
|
*/
|
56
|
-
void grpc_rb_md_ary_convert(VALUE md_ary_hash,
|
57
|
-
grpc_metadata_array *md_ary);
|
56
|
+
void grpc_rb_md_ary_convert(VALUE md_ary_hash, grpc_metadata_array *md_ary);
|
58
57
|
|
59
58
|
/* grpc_rb_eCallError is the ruby class of the exception thrown during call
|
60
59
|
operations. */
|
@@ -33,8 +33,8 @@
|
|
33
33
|
|
34
34
|
#include <ruby/ruby.h>
|
35
35
|
|
36
|
-
#include "rb_grpc_imports.generated.h"
|
37
36
|
#include "rb_call_credentials.h"
|
37
|
+
#include "rb_grpc_imports.generated.h"
|
38
38
|
|
39
39
|
#include <ruby/thread.h>
|
40
40
|
|
@@ -82,20 +82,18 @@ static VALUE grpc_rb_call_credentials_callback(VALUE callback_args) {
|
|
82
82
|
static VALUE grpc_rb_call_credentials_callback_rescue(VALUE args,
|
83
83
|
VALUE exception_object) {
|
84
84
|
VALUE result = rb_hash_new();
|
85
|
-
VALUE backtrace =
|
86
|
-
rb_funcall(exception_object, rb_intern("backtrace"), 0),
|
87
|
-
|
88
|
-
|
89
|
-
|
85
|
+
VALUE backtrace =
|
86
|
+
rb_funcall(rb_funcall(exception_object, rb_intern("backtrace"), 0),
|
87
|
+
rb_intern("join"), 1, rb_str_new2("\n\tfrom "));
|
88
|
+
VALUE rb_exception_info =
|
89
|
+
rb_funcall(exception_object, rb_intern("inspect"), 0);
|
90
90
|
(void)args;
|
91
91
|
gpr_log(GPR_INFO, "Call credentials callback failed: %s\n%s",
|
92
|
-
StringValueCStr(rb_exception_info),
|
93
|
-
StringValueCStr(backtrace));
|
92
|
+
StringValueCStr(rb_exception_info), StringValueCStr(backtrace));
|
94
93
|
rb_hash_aset(result, rb_str_new2("metadata"), Qnil);
|
95
94
|
rb_hash_aset(result, rb_str_new2("status"),
|
96
95
|
INT2NUM(GRPC_STATUS_UNAUTHENTICATED));
|
97
|
-
rb_hash_aset(result, rb_str_new2("details"),
|
98
|
-
rb_exception_info);
|
96
|
+
rb_hash_aset(result, rb_str_new2("details"), rb_exception_info);
|
99
97
|
return result;
|
100
98
|
}
|
101
99
|
|
@@ -118,7 +116,8 @@ static void grpc_rb_call_credentials_callback_with_gil(void *param) {
|
|
118
116
|
result = rb_rescue(grpc_rb_call_credentials_callback, callback_args,
|
119
117
|
grpc_rb_call_credentials_callback_rescue, Qnil);
|
120
118
|
// Both callbacks return a hash, so result should be a hash
|
121
|
-
grpc_rb_md_ary_convert(rb_hash_aref(result, rb_str_new2("metadata")),
|
119
|
+
grpc_rb_md_ary_convert(rb_hash_aref(result, rb_str_new2("metadata")),
|
120
|
+
&md_ary);
|
122
121
|
status = NUM2INT(rb_hash_aref(result, rb_str_new2("status")));
|
123
122
|
details = rb_hash_aref(result, rb_str_new2("details"));
|
124
123
|
error_details = StringValueCStr(details);
|
@@ -138,7 +137,7 @@ static void grpc_rb_call_credentials_plugin_get_metadata(
|
|
138
137
|
params->callback = cb;
|
139
138
|
|
140
139
|
grpc_rb_event_queue_enqueue(grpc_rb_call_credentials_callback_with_gil,
|
141
|
-
(void*)(params));
|
140
|
+
(void *)(params));
|
142
141
|
}
|
143
142
|
|
144
143
|
static void grpc_rb_call_credentials_plugin_destroy(void *state) {
|
@@ -172,13 +171,15 @@ static void grpc_rb_call_credentials_mark(void *p) {
|
|
172
171
|
}
|
173
172
|
|
174
173
|
static rb_data_type_t grpc_rb_call_credentials_data_type = {
|
175
|
-
|
176
|
-
|
177
|
-
|
178
|
-
|
179
|
-
|
174
|
+
"grpc_call_credentials",
|
175
|
+
{grpc_rb_call_credentials_mark,
|
176
|
+
grpc_rb_call_credentials_free,
|
177
|
+
GRPC_RB_MEMSIZE_UNAVAILABLE,
|
178
|
+
{NULL, NULL}},
|
179
|
+
NULL,
|
180
|
+
NULL,
|
180
181
|
#ifdef RUBY_TYPED_FREE_IMMEDIATELY
|
181
|
-
|
182
|
+
RUBY_TYPED_FREE_IMMEDIATELY
|
182
183
|
#endif
|
183
184
|
};
|
184
185
|
|
@@ -188,7 +189,8 @@ static VALUE grpc_rb_call_credentials_alloc(VALUE cls) {
|
|
188
189
|
grpc_rb_call_credentials *wrapper = ALLOC(grpc_rb_call_credentials);
|
189
190
|
wrapper->wrapped = NULL;
|
190
191
|
wrapper->mark = Qnil;
|
191
|
-
return TypedData_Wrap_Struct(cls, &grpc_rb_call_credentials_data_type,
|
192
|
+
return TypedData_Wrap_Struct(cls, &grpc_rb_call_credentials_data_type,
|
193
|
+
wrapper);
|
192
194
|
}
|
193
195
|
|
194
196
|
/* Creates a wrapping object for a given call credentials. This should only be
|
@@ -232,7 +234,7 @@ static VALUE grpc_rb_call_credentials_init(VALUE self, VALUE proc) {
|
|
232
234
|
rb_raise(rb_eTypeError, "Argument to CallCredentials#new must be a proc");
|
233
235
|
return Qnil;
|
234
236
|
}
|
235
|
-
plugin.state = (void*)proc;
|
237
|
+
plugin.state = (void *)proc;
|
236
238
|
plugin.type = "";
|
237
239
|
|
238
240
|
creds = grpc_metadata_credentials_create_from_plugin(plugin, NULL);
|
@@ -289,7 +291,6 @@ void Init_grpc_call_credentials() {
|
|
289
291
|
grpc_call_credentials *grpc_rb_get_wrapped_call_credentials(VALUE v) {
|
290
292
|
grpc_rb_call_credentials *wrapper = NULL;
|
291
293
|
TypedData_Get_Struct(v, grpc_rb_call_credentials,
|
292
|
-
&grpc_rb_call_credentials_data_type,
|
293
|
-
wrapper);
|
294
|
+
&grpc_rb_call_credentials_data_type, wrapper);
|
294
295
|
return wrapper->wrapped;
|
295
296
|
}
|