grpc 0.14.1-x64-mingw32 → 0.15.0-x64-mingw32
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/bin/math_services.rb +41 -2
- data/src/ruby/ext/grpc/rb_call.c +42 -40
- data/src/ruby/ext/grpc/rb_channel.c +1 -1
- data/src/ruby/ext/grpc/rb_completion_queue.c +59 -6
- data/src/ruby/ext/grpc/rb_completion_queue.h +1 -1
- data/src/ruby/ext/grpc/rb_grpc.c +1 -3
- data/src/ruby/ext/grpc/rb_grpc_imports.generated.c +12 -2
- data/src/ruby/ext/grpc/rb_grpc_imports.generated.h +21 -5
- data/src/ruby/ext/grpc/rb_loader.c +1 -1
- data/src/ruby/ext/grpc/rb_server.c +5 -3
- data/src/ruby/lib/grpc.rb +0 -3
- 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/errors.rb +3 -2
- data/src/ruby/lib/grpc/generic/active_call.rb +32 -42
- data/src/ruby/lib/grpc/generic/bidi_call.rb +20 -0
- data/src/ruby/lib/grpc/generic/client_stub.rb +31 -54
- data/src/ruby/lib/grpc/generic/rpc_desc.rb +4 -4
- data/src/ruby/lib/grpc/generic/rpc_server.rb +12 -23
- data/src/ruby/lib/grpc/generic/service.rb +8 -8
- 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/v1/health_services.rb +30 -2
- data/src/ruby/pb/grpc/testing/duplicate/echo_duplicate_services.rb +34 -4
- data/src/ruby/pb/grpc/testing/metrics_services.rb +39 -2
- data/src/ruby/pb/src/proto/grpc/testing/empty.rb +15 -0
- data/src/ruby/pb/src/proto/grpc/testing/messages.rb +84 -0
- data/src/ruby/pb/src/proto/grpc/testing/test.rb +14 -0
- data/src/ruby/pb/src/proto/grpc/testing/test_services.rb +110 -0
- data/src/ruby/pb/test/client.rb +5 -2
- data/src/ruby/spec/generic/active_call_spec.rb +3 -2
- data/src/ruby/spec/generic/client_stub_spec.rb +27 -24
- data/src/ruby/spec/generic/rpc_desc_spec.rb +11 -11
- data/src/ruby/spec/generic/rpc_server_spec.rb +42 -61
- data/src/ruby/spec/pb/health/checker_spec.rb +3 -5
- metadata +6 -5
- data/src/ruby/ext/grpc/rb_signal.c +0 -70
- data/src/ruby/ext/grpc/rb_signal.h +0 -39
- data/src/ruby/lib/grpc/signals.rb +0 -69
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: adcfb5f988a45fcca12f2fa0d0c5b33f011f8076
|
4
|
+
data.tar.gz: 9a7418633dc0e17204c400cf9541f3de692fb623
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 9c9aa706a9419ec2623a87f21afabdcf934f011d1fe65259c9c69c4ce537e8d059a9db8bcf1d4c3400be08fb962828050f1fd18261290a3c021caa23cba68935
|
7
|
+
data.tar.gz: edf1c5e418c3a90cc7b99c335d7de16a829ca892c245792231f4a2a5155347c11e3ce7d9dfa0d97fe5edf5a0dd04e9d2835d4a19053773dbc5f04616b850c379
|
data/grpc_c.32.ruby
CHANGED
Binary file
|
data/grpc_c.64.ruby
CHANGED
Binary file
|
@@ -1,13 +1,41 @@
|
|
1
1
|
# Generated by the protocol buffer compiler. DO NOT EDIT!
|
2
2
|
# Source: math.proto for package 'math'
|
3
|
+
# Original file comments:
|
4
|
+
# Copyright 2015, Google Inc.
|
5
|
+
# All rights reserved.
|
6
|
+
#
|
7
|
+
# Redistribution and use in source and binary forms, with or without
|
8
|
+
# modification, are permitted provided that the following conditions are
|
9
|
+
# met:
|
10
|
+
#
|
11
|
+
# * Redistributions of source code must retain the above copyright
|
12
|
+
# notice, this list of conditions and the following disclaimer.
|
13
|
+
# * Redistributions in binary form must reproduce the above
|
14
|
+
# copyright notice, this list of conditions and the following disclaimer
|
15
|
+
# in the documentation and/or other materials provided with the
|
16
|
+
# distribution.
|
17
|
+
# * Neither the name of Google Inc. nor the names of its
|
18
|
+
# contributors may be used to endorse or promote products derived from
|
19
|
+
# this software without specific prior written permission.
|
20
|
+
#
|
21
|
+
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
22
|
+
# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
23
|
+
# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
24
|
+
# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
25
|
+
# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
26
|
+
# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
27
|
+
# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
28
|
+
# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
29
|
+
# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
30
|
+
# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
31
|
+
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
32
|
+
#
|
3
33
|
|
4
34
|
require 'grpc'
|
5
35
|
require 'math'
|
6
36
|
|
7
37
|
module Math
|
8
38
|
module Math
|
9
|
-
|
10
|
-
# TODO: add proto service documentation here
|
11
39
|
class Service
|
12
40
|
|
13
41
|
include GRPC::GenericService
|
@@ -16,9 +44,20 @@ module Math
|
|
16
44
|
self.unmarshal_class_method = :decode
|
17
45
|
self.service_name = 'math.Math'
|
18
46
|
|
47
|
+
# Div divides args.dividend by args.divisor and returns the quotient and
|
48
|
+
# remainder.
|
19
49
|
rpc :Div, DivArgs, DivReply
|
50
|
+
# DivMany accepts an arbitrary number of division args from the client stream
|
51
|
+
# and sends back the results in the reply stream. The stream continues until
|
52
|
+
# the client closes its end; the server does the same after sending all the
|
53
|
+
# replies. The stream ends immediately if either end aborts.
|
20
54
|
rpc :DivMany, stream(DivArgs), stream(DivReply)
|
55
|
+
# Fib generates numbers in the Fibonacci sequence. If args.limit > 0, Fib
|
56
|
+
# generates up to limit numbers; otherwise it continues until the call is
|
57
|
+
# canceled. Unlike Fib above, Fib has no final FibReply.
|
21
58
|
rpc :Fib, FibArgs, stream(Num)
|
59
|
+
# Sum sums a stream of numbers, returning the final result once the stream
|
60
|
+
# is closed.
|
22
61
|
rpc :Sum, stream(Num), Num
|
23
62
|
end
|
24
63
|
|
data/src/ruby/ext/grpc/rb_call.c
CHANGED
@@ -101,30 +101,14 @@ static VALUE sym_message;
|
|
101
101
|
static VALUE sym_status;
|
102
102
|
static VALUE sym_cancelled;
|
103
103
|
|
104
|
-
/* hash_all_calls is a hash of Call address -> reference count that is used to
|
105
|
-
* track the creation and destruction of rb_call instances.
|
106
|
-
*/
|
107
|
-
static VALUE hash_all_calls;
|
108
|
-
|
109
104
|
/* Destroys a Call. */
|
110
105
|
static void grpc_rb_call_destroy(void *p) {
|
111
|
-
grpc_call
|
112
|
-
VALUE ref_count = Qnil;
|
106
|
+
grpc_call* call = NULL;
|
113
107
|
if (p == NULL) {
|
114
108
|
return;
|
115
|
-
};
|
116
|
-
call = (grpc_call *)p;
|
117
|
-
|
118
|
-
ref_count = rb_hash_aref(hash_all_calls, OFFT2NUM((VALUE)call));
|
119
|
-
if (ref_count == Qnil) {
|
120
|
-
return; /* No longer in the hash, so already deleted */
|
121
|
-
} else if (NUM2UINT(ref_count) == 1) {
|
122
|
-
rb_hash_delete(hash_all_calls, OFFT2NUM((VALUE)call));
|
123
|
-
grpc_call_destroy(call);
|
124
|
-
} else {
|
125
|
-
rb_hash_aset(hash_all_calls, OFFT2NUM((VALUE)call),
|
126
|
-
UINT2NUM(NUM2UINT(ref_count) - 1));
|
127
109
|
}
|
110
|
+
call = (grpc_call *)p;
|
111
|
+
grpc_call_destroy(call);
|
128
112
|
}
|
129
113
|
|
130
114
|
static size_t md_ary_datasize(const void *p) {
|
@@ -151,7 +135,7 @@ static const rb_data_type_t grpc_rb_md_ary_data_type = {
|
|
151
135
|
* touches a hash object.
|
152
136
|
* TODO(yugui) Directly use st_table and call the free function earlier?
|
153
137
|
*/
|
154
|
-
|
138
|
+
0,
|
155
139
|
#endif
|
156
140
|
};
|
157
141
|
|
@@ -163,12 +147,7 @@ static const rb_data_type_t grpc_call_data_type = {
|
|
163
147
|
NULL,
|
164
148
|
NULL,
|
165
149
|
#ifdef RUBY_TYPED_FREE_IMMEDIATELY
|
166
|
-
|
167
|
-
* grpc_rb_call_destroy
|
168
|
-
* touches a hash object.
|
169
|
-
* TODO(yugui) Directly use st_table and call the free function earlier?
|
170
|
-
*/
|
171
|
-
0,
|
150
|
+
RUBY_TYPED_FREE_IMMEDIATELY
|
172
151
|
#endif
|
173
152
|
};
|
174
153
|
|
@@ -190,6 +169,11 @@ const char *grpc_call_error_detail_of(grpc_call_error err) {
|
|
190
169
|
static VALUE grpc_rb_call_cancel(VALUE self) {
|
191
170
|
grpc_call *call = NULL;
|
192
171
|
grpc_call_error err;
|
172
|
+
if (RTYPEDDATA_DATA(self) == NULL) {
|
173
|
+
//This call has been closed
|
174
|
+
return Qnil;
|
175
|
+
}
|
176
|
+
|
193
177
|
TypedData_Get_Struct(self, grpc_call, &grpc_call_data_type, call);
|
194
178
|
err = grpc_call_cancel(call, NULL);
|
195
179
|
if (err != GRPC_CALL_OK) {
|
@@ -200,11 +184,29 @@ static VALUE grpc_rb_call_cancel(VALUE self) {
|
|
200
184
|
return Qnil;
|
201
185
|
}
|
202
186
|
|
187
|
+
/* Releases the c-level resources associated with a call
|
188
|
+
Once a call has been closed, no further requests can be
|
189
|
+
processed.
|
190
|
+
*/
|
191
|
+
static VALUE grpc_rb_call_close(VALUE self) {
|
192
|
+
grpc_call *call = NULL;
|
193
|
+
TypedData_Get_Struct(self, grpc_call, &grpc_call_data_type, call);
|
194
|
+
if(call != NULL) {
|
195
|
+
grpc_call_destroy(call);
|
196
|
+
RTYPEDDATA_DATA(self) = NULL;
|
197
|
+
}
|
198
|
+
return Qnil;
|
199
|
+
}
|
200
|
+
|
203
201
|
/* Called to obtain the peer that this call is connected to. */
|
204
202
|
static VALUE grpc_rb_call_get_peer(VALUE self) {
|
205
203
|
VALUE res = Qnil;
|
206
204
|
grpc_call *call = NULL;
|
207
205
|
char *peer = NULL;
|
206
|
+
if (RTYPEDDATA_DATA(self) == NULL) {
|
207
|
+
rb_raise(grpc_rb_eCallError, "Cannot get peer value on closed call");
|
208
|
+
return Qnil;
|
209
|
+
}
|
208
210
|
TypedData_Get_Struct(self, grpc_call, &grpc_call_data_type, call);
|
209
211
|
peer = grpc_call_get_peer(call);
|
210
212
|
res = rb_str_new2(peer);
|
@@ -218,6 +220,10 @@ static VALUE grpc_rb_call_get_peer_cert(VALUE self) {
|
|
218
220
|
grpc_call *call = NULL;
|
219
221
|
VALUE res = Qnil;
|
220
222
|
grpc_auth_context *ctx = NULL;
|
223
|
+
if (RTYPEDDATA_DATA(self) == NULL) {
|
224
|
+
rb_raise(grpc_rb_eCallError, "Cannot get peer cert on closed call");
|
225
|
+
return Qnil;
|
226
|
+
}
|
221
227
|
TypedData_Get_Struct(self, grpc_call, &grpc_call_data_type, call);
|
222
228
|
|
223
229
|
ctx = grpc_call_auth_context(call);
|
@@ -323,6 +329,10 @@ static VALUE grpc_rb_call_set_credentials(VALUE self, VALUE credentials) {
|
|
323
329
|
grpc_call *call = NULL;
|
324
330
|
grpc_call_credentials *creds;
|
325
331
|
grpc_call_error err;
|
332
|
+
if (RTYPEDDATA_DATA(self) == NULL) {
|
333
|
+
rb_raise(grpc_rb_eCallError, "Cannot set credentials of closed call");
|
334
|
+
return Qnil;
|
335
|
+
}
|
326
336
|
TypedData_Get_Struct(self, grpc_call, &grpc_call_data_type, call);
|
327
337
|
creds = grpc_rb_get_wrapped_call_credentials(credentials);
|
328
338
|
err = grpc_call_set_credentials(call, creds);
|
@@ -731,7 +741,7 @@ static VALUE grpc_run_batch_stack_build_result(run_batch_stack *st) {
|
|
731
741
|
}
|
732
742
|
tag = Object.new
|
733
743
|
timeout = 10
|
734
|
-
call.start_batch(
|
744
|
+
call.start_batch(cq, tag, timeout, ops)
|
735
745
|
|
736
746
|
Start a batch of operations defined in the array ops; when complete, post a
|
737
747
|
completion of type 'tag' to the completion queue bound to the call.
|
@@ -749,6 +759,10 @@ static VALUE grpc_rb_call_run_batch(VALUE self, VALUE cqueue, VALUE tag,
|
|
749
759
|
VALUE result = Qnil;
|
750
760
|
VALUE rb_write_flag = rb_ivar_get(self, id_write_flag);
|
751
761
|
unsigned write_flag = 0;
|
762
|
+
if (RTYPEDDATA_DATA(self) == NULL) {
|
763
|
+
rb_raise(grpc_rb_eCallError, "Cannot run batch on closed call");
|
764
|
+
return Qnil;
|
765
|
+
}
|
752
766
|
TypedData_Get_Struct(self, grpc_call, &grpc_call_data_type, call);
|
753
767
|
|
754
768
|
/* Validate the ops args, adding them to a ruby array */
|
@@ -888,6 +902,7 @@ void Init_grpc_call() {
|
|
888
902
|
/* Add ruby analogues of the Call methods. */
|
889
903
|
rb_define_method(grpc_rb_cCall, "run_batch", grpc_rb_call_run_batch, 4);
|
890
904
|
rb_define_method(grpc_rb_cCall, "cancel", grpc_rb_call_cancel, 0);
|
905
|
+
rb_define_method(grpc_rb_cCall, "close", grpc_rb_call_close, 0);
|
891
906
|
rb_define_method(grpc_rb_cCall, "peer", grpc_rb_call_get_peer, 0);
|
892
907
|
rb_define_method(grpc_rb_cCall, "peer_cert", grpc_rb_call_get_peer_cert, 0);
|
893
908
|
rb_define_method(grpc_rb_cCall, "status", grpc_rb_call_get_status, 0);
|
@@ -925,11 +940,6 @@ void Init_grpc_call() {
|
|
925
940
|
"BatchResult", "send_message", "send_metadata", "send_close",
|
926
941
|
"send_status", "message", "metadata", "status", "cancelled", NULL);
|
927
942
|
|
928
|
-
/* The hash for reference counting calls, to ensure they can't be destroyed
|
929
|
-
* more than once */
|
930
|
-
hash_all_calls = rb_hash_new();
|
931
|
-
rb_define_const(grpc_rb_cCall, "INTERNAL_ALL_CALLs", hash_all_calls);
|
932
|
-
|
933
943
|
Init_grpc_error_codes();
|
934
944
|
Init_grpc_op_codes();
|
935
945
|
Init_grpc_write_flags();
|
@@ -944,16 +954,8 @@ grpc_call *grpc_rb_get_wrapped_call(VALUE v) {
|
|
944
954
|
|
945
955
|
/* Obtains the wrapped object for a given call */
|
946
956
|
VALUE grpc_rb_wrap_call(grpc_call *c) {
|
947
|
-
VALUE obj = Qnil;
|
948
957
|
if (c == NULL) {
|
949
958
|
return Qnil;
|
950
959
|
}
|
951
|
-
obj = rb_hash_aref(hash_all_calls, OFFT2NUM((VALUE)c));
|
952
|
-
if (obj == Qnil) { /* Not in the hash add it */
|
953
|
-
rb_hash_aset(hash_all_calls, OFFT2NUM((VALUE)c), UINT2NUM(1));
|
954
|
-
} else {
|
955
|
-
rb_hash_aset(hash_all_calls, OFFT2NUM((VALUE)c),
|
956
|
-
UINT2NUM(NUM2UINT(obj) + 1));
|
957
|
-
}
|
958
960
|
return TypedData_Wrap_Struct(grpc_rb_cCall, &grpc_call_data_type, c);
|
959
961
|
}
|
@@ -373,7 +373,7 @@ static void Init_grpc_connectivity_states() {
|
|
373
373
|
rb_define_const(grpc_rb_mConnectivityStates, "TRANSIENT_FAILURE",
|
374
374
|
LONG2NUM(GRPC_CHANNEL_TRANSIENT_FAILURE));
|
375
375
|
rb_define_const(grpc_rb_mConnectivityStates, "FATAL_FAILURE",
|
376
|
-
LONG2NUM(
|
376
|
+
LONG2NUM(GRPC_CHANNEL_SHUTDOWN));
|
377
377
|
}
|
378
378
|
|
379
379
|
void Init_grpc_channel() {
|
@@ -52,21 +52,41 @@ typedef struct next_call_stack {
|
|
52
52
|
grpc_event event;
|
53
53
|
gpr_timespec timeout;
|
54
54
|
void *tag;
|
55
|
+
volatile int interrupted;
|
55
56
|
} next_call_stack;
|
56
57
|
|
57
58
|
/* Calls grpc_completion_queue_next without holding the ruby GIL */
|
58
59
|
static void *grpc_rb_completion_queue_next_no_gil(void *param) {
|
59
60
|
next_call_stack *const next_call = (next_call_stack*)param;
|
60
|
-
|
61
|
-
|
61
|
+
gpr_timespec increment = gpr_time_from_millis(20, GPR_TIMESPAN);
|
62
|
+
gpr_timespec deadline;
|
63
|
+
do {
|
64
|
+
deadline = gpr_time_add(gpr_now(GPR_CLOCK_REALTIME), increment);
|
65
|
+
next_call->event = grpc_completion_queue_next(next_call->cq,
|
66
|
+
deadline, NULL);
|
67
|
+
if (next_call->event.type != GRPC_QUEUE_TIMEOUT ||
|
68
|
+
gpr_time_cmp(deadline, next_call->timeout) > 0) {
|
69
|
+
break;
|
70
|
+
}
|
71
|
+
} while (!next_call->interrupted);
|
62
72
|
return NULL;
|
63
73
|
}
|
64
74
|
|
65
75
|
/* Calls grpc_completion_queue_pluck without holding the ruby GIL */
|
66
76
|
static void *grpc_rb_completion_queue_pluck_no_gil(void *param) {
|
67
77
|
next_call_stack *const next_call = (next_call_stack*)param;
|
68
|
-
|
69
|
-
|
78
|
+
gpr_timespec increment = gpr_time_from_millis(20, GPR_TIMESPAN);
|
79
|
+
gpr_timespec deadline;
|
80
|
+
do {
|
81
|
+
deadline = gpr_time_add(gpr_now(GPR_CLOCK_REALTIME), increment);
|
82
|
+
next_call->event = grpc_completion_queue_pluck(next_call->cq,
|
83
|
+
next_call->tag,
|
84
|
+
deadline, NULL);
|
85
|
+
if (next_call->event.type != GRPC_QUEUE_TIMEOUT ||
|
86
|
+
gpr_time_cmp(deadline, next_call->timeout) > 0) {
|
87
|
+
break;
|
88
|
+
}
|
89
|
+
} while (!next_call->interrupted);
|
70
90
|
return NULL;
|
71
91
|
}
|
72
92
|
|
@@ -130,6 +150,14 @@ static rb_data_type_t grpc_rb_completion_queue_data_type = {
|
|
130
150
|
#endif
|
131
151
|
};
|
132
152
|
|
153
|
+
/* Releases the c-level resources associated with a completion queue */
|
154
|
+
static VALUE grpc_rb_completion_queue_close(VALUE self) {
|
155
|
+
grpc_completion_queue* cq = grpc_rb_get_wrapped_completion_queue(self);
|
156
|
+
grpc_rb_completion_queue_destroy(cq);
|
157
|
+
RTYPEDDATA_DATA(self) = NULL;
|
158
|
+
return Qnil;
|
159
|
+
}
|
160
|
+
|
133
161
|
/* Allocates a completion queue. */
|
134
162
|
static VALUE grpc_rb_completion_queue_alloc(VALUE cls) {
|
135
163
|
grpc_completion_queue *cq = grpc_completion_queue_create(NULL);
|
@@ -139,6 +167,11 @@ static VALUE grpc_rb_completion_queue_alloc(VALUE cls) {
|
|
139
167
|
return TypedData_Wrap_Struct(cls, &grpc_rb_completion_queue_data_type, cq);
|
140
168
|
}
|
141
169
|
|
170
|
+
static void unblock_func(void *param) {
|
171
|
+
next_call_stack *const next_call = (next_call_stack*)param;
|
172
|
+
next_call->interrupted = 1;
|
173
|
+
}
|
174
|
+
|
142
175
|
/* Blocks until the next event for given tag is available, and returns the
|
143
176
|
* event. */
|
144
177
|
grpc_event grpc_rb_completion_queue_pluck_event(VALUE self, VALUE tag,
|
@@ -158,8 +191,23 @@ grpc_event grpc_rb_completion_queue_pluck_event(VALUE self, VALUE tag,
|
|
158
191
|
next_call.tag = ROBJECT(tag);
|
159
192
|
}
|
160
193
|
next_call.event.type = GRPC_QUEUE_TIMEOUT;
|
161
|
-
|
162
|
-
|
194
|
+
/* Loop until we finish a pluck without an interruption. The internal
|
195
|
+
pluck function runs either until it is interrupted or it gets an
|
196
|
+
event, or time runs out.
|
197
|
+
|
198
|
+
The basic reason we need this relatively complicated construction is that
|
199
|
+
we need to re-acquire the GVL when an interrupt comes in, so that the ruby
|
200
|
+
interpreter can do what it needs to do with the interrupt. But we also need
|
201
|
+
to get back to plucking when the interrupt has been handled. */
|
202
|
+
do {
|
203
|
+
next_call.interrupted = 0;
|
204
|
+
rb_thread_call_without_gvl(grpc_rb_completion_queue_pluck_no_gil,
|
205
|
+
(void *)&next_call, unblock_func,
|
206
|
+
(void *)&next_call);
|
207
|
+
/* If an interrupt prevented pluck from returning useful information, then
|
208
|
+
any plucks that did complete must have timed out */
|
209
|
+
} while (next_call.interrupted &&
|
210
|
+
next_call.event.type == GRPC_QUEUE_TIMEOUT);
|
163
211
|
return next_call.event;
|
164
212
|
}
|
165
213
|
|
@@ -172,6 +220,11 @@ void Init_grpc_completion_queue() {
|
|
172
220
|
this func, so no separate initialization step is necessary. */
|
173
221
|
rb_define_alloc_func(grpc_rb_cCompletionQueue,
|
174
222
|
grpc_rb_completion_queue_alloc);
|
223
|
+
|
224
|
+
/* close: Provides a way to close the underlying file descriptor without
|
225
|
+
waiting for ruby garbage collection. */
|
226
|
+
rb_define_method(grpc_rb_cCompletionQueue, "close",
|
227
|
+
grpc_rb_completion_queue_close, 0);
|
175
228
|
}
|
176
229
|
|
177
230
|
/* Gets the wrapped completion queue from the ruby wrapper */
|
@@ -46,7 +46,7 @@ grpc_completion_queue *grpc_rb_get_wrapped_completion_queue(VALUE v);
|
|
46
46
|
*
|
47
47
|
* This avoids having code that holds the GIL repeated at multiple sites.
|
48
48
|
*/
|
49
|
-
grpc_event grpc_rb_completion_queue_pluck_event(VALUE
|
49
|
+
grpc_event grpc_rb_completion_queue_pluck_event(VALUE self, VALUE tag,
|
50
50
|
VALUE timeout);
|
51
51
|
|
52
52
|
/* Initializes the CompletionQueue class. */
|
data/src/ruby/ext/grpc/rb_grpc.c
CHANGED
@@ -50,7 +50,6 @@
|
|
50
50
|
#include "rb_loader.h"
|
51
51
|
#include "rb_server.h"
|
52
52
|
#include "rb_server_credentials.h"
|
53
|
-
#include "rb_signal.h"
|
54
53
|
|
55
54
|
static VALUE grpc_rb_cTimeVal = Qnil;
|
56
55
|
|
@@ -319,7 +318,7 @@ void Init_grpc_c() {
|
|
319
318
|
grpc_rb_mGrpcCore = rb_define_module_under(grpc_rb_mGRPC, "Core");
|
320
319
|
grpc_rb_sNewServerRpc =
|
321
320
|
rb_struct_define("NewServerRpc", "method", "host",
|
322
|
-
"deadline", "metadata", "call", NULL);
|
321
|
+
"deadline", "metadata", "call", "cq", NULL);
|
323
322
|
grpc_rb_sStatus =
|
324
323
|
rb_struct_define("Status", "code", "details", "metadata", NULL);
|
325
324
|
sym_code = ID2SYM(rb_intern("code"));
|
@@ -333,7 +332,6 @@ void Init_grpc_c() {
|
|
333
332
|
Init_grpc_channel_credentials();
|
334
333
|
Init_grpc_server();
|
335
334
|
Init_grpc_server_credentials();
|
336
|
-
Init_grpc_signals();
|
337
335
|
Init_grpc_status_codes();
|
338
336
|
Init_grpc_time_consts();
|
339
337
|
}
|
@@ -33,7 +33,7 @@
|
|
33
33
|
|
34
34
|
#include <grpc/support/port_platform.h>
|
35
35
|
|
36
|
-
#ifdef
|
36
|
+
#ifdef GPR_WINDOWS
|
37
37
|
|
38
38
|
#include "rb_grpc_imports.generated.h"
|
39
39
|
|
@@ -115,6 +115,7 @@ grpc_server_register_method_type grpc_server_register_method_import;
|
|
115
115
|
grpc_server_request_registered_call_type grpc_server_request_registered_call_import;
|
116
116
|
grpc_server_create_type grpc_server_create_import;
|
117
117
|
grpc_server_register_completion_queue_type grpc_server_register_completion_queue_import;
|
118
|
+
grpc_server_register_non_listening_completion_queue_type grpc_server_register_non_listening_completion_queue_import;
|
118
119
|
grpc_server_add_insecure_http2_port_type grpc_server_add_insecure_http2_port_import;
|
119
120
|
grpc_server_start_type grpc_server_start_import;
|
120
121
|
grpc_server_shutdown_and_notify_type grpc_server_shutdown_and_notify_import;
|
@@ -125,6 +126,8 @@ grpc_header_key_is_legal_type grpc_header_key_is_legal_import;
|
|
125
126
|
grpc_header_nonbin_value_is_legal_type grpc_header_nonbin_value_is_legal_import;
|
126
127
|
grpc_is_binary_header_type grpc_is_binary_header_import;
|
127
128
|
grpc_call_error_to_string_type grpc_call_error_to_string_import;
|
129
|
+
grpc_insecure_channel_create_from_fd_type grpc_insecure_channel_create_from_fd_import;
|
130
|
+
grpc_server_add_insecure_channel_from_fd_type grpc_server_add_insecure_channel_from_fd_import;
|
128
131
|
grpc_auth_property_iterator_next_type grpc_auth_property_iterator_next_import;
|
129
132
|
grpc_auth_context_property_iterator_type grpc_auth_context_property_iterator_import;
|
130
133
|
grpc_auth_context_peer_identity_type grpc_auth_context_peer_identity_import;
|
@@ -257,6 +260,8 @@ gpr_avl_unref_type gpr_avl_unref_import;
|
|
257
260
|
gpr_avl_add_type gpr_avl_add_import;
|
258
261
|
gpr_avl_remove_type gpr_avl_remove_import;
|
259
262
|
gpr_avl_get_type gpr_avl_get_import;
|
263
|
+
gpr_avl_maybe_get_type gpr_avl_maybe_get_import;
|
264
|
+
gpr_avl_is_empty_type gpr_avl_is_empty_import;
|
260
265
|
gpr_cmdline_create_type gpr_cmdline_create_import;
|
261
266
|
gpr_cmdline_add_int_type gpr_cmdline_add_int_import;
|
262
267
|
gpr_cmdline_add_flag_type gpr_cmdline_add_flag_import;
|
@@ -381,6 +386,7 @@ void grpc_rb_load_imports(HMODULE library) {
|
|
381
386
|
grpc_server_request_registered_call_import = (grpc_server_request_registered_call_type) GetProcAddress(library, "grpc_server_request_registered_call");
|
382
387
|
grpc_server_create_import = (grpc_server_create_type) GetProcAddress(library, "grpc_server_create");
|
383
388
|
grpc_server_register_completion_queue_import = (grpc_server_register_completion_queue_type) GetProcAddress(library, "grpc_server_register_completion_queue");
|
389
|
+
grpc_server_register_non_listening_completion_queue_import = (grpc_server_register_non_listening_completion_queue_type) GetProcAddress(library, "grpc_server_register_non_listening_completion_queue");
|
384
390
|
grpc_server_add_insecure_http2_port_import = (grpc_server_add_insecure_http2_port_type) GetProcAddress(library, "grpc_server_add_insecure_http2_port");
|
385
391
|
grpc_server_start_import = (grpc_server_start_type) GetProcAddress(library, "grpc_server_start");
|
386
392
|
grpc_server_shutdown_and_notify_import = (grpc_server_shutdown_and_notify_type) GetProcAddress(library, "grpc_server_shutdown_and_notify");
|
@@ -391,6 +397,8 @@ void grpc_rb_load_imports(HMODULE library) {
|
|
391
397
|
grpc_header_nonbin_value_is_legal_import = (grpc_header_nonbin_value_is_legal_type) GetProcAddress(library, "grpc_header_nonbin_value_is_legal");
|
392
398
|
grpc_is_binary_header_import = (grpc_is_binary_header_type) GetProcAddress(library, "grpc_is_binary_header");
|
393
399
|
grpc_call_error_to_string_import = (grpc_call_error_to_string_type) GetProcAddress(library, "grpc_call_error_to_string");
|
400
|
+
grpc_insecure_channel_create_from_fd_import = (grpc_insecure_channel_create_from_fd_type) GetProcAddress(library, "grpc_insecure_channel_create_from_fd");
|
401
|
+
grpc_server_add_insecure_channel_from_fd_import = (grpc_server_add_insecure_channel_from_fd_type) GetProcAddress(library, "grpc_server_add_insecure_channel_from_fd");
|
394
402
|
grpc_auth_property_iterator_next_import = (grpc_auth_property_iterator_next_type) GetProcAddress(library, "grpc_auth_property_iterator_next");
|
395
403
|
grpc_auth_context_property_iterator_import = (grpc_auth_context_property_iterator_type) GetProcAddress(library, "grpc_auth_context_property_iterator");
|
396
404
|
grpc_auth_context_peer_identity_import = (grpc_auth_context_peer_identity_type) GetProcAddress(library, "grpc_auth_context_peer_identity");
|
@@ -523,6 +531,8 @@ void grpc_rb_load_imports(HMODULE library) {
|
|
523
531
|
gpr_avl_add_import = (gpr_avl_add_type) GetProcAddress(library, "gpr_avl_add");
|
524
532
|
gpr_avl_remove_import = (gpr_avl_remove_type) GetProcAddress(library, "gpr_avl_remove");
|
525
533
|
gpr_avl_get_import = (gpr_avl_get_type) GetProcAddress(library, "gpr_avl_get");
|
534
|
+
gpr_avl_maybe_get_import = (gpr_avl_maybe_get_type) GetProcAddress(library, "gpr_avl_maybe_get");
|
535
|
+
gpr_avl_is_empty_import = (gpr_avl_is_empty_type) GetProcAddress(library, "gpr_avl_is_empty");
|
526
536
|
gpr_cmdline_create_import = (gpr_cmdline_create_type) GetProcAddress(library, "gpr_cmdline_create");
|
527
537
|
gpr_cmdline_add_int_import = (gpr_cmdline_add_int_type) GetProcAddress(library, "gpr_cmdline_add_int");
|
528
538
|
gpr_cmdline_add_flag_import = (gpr_cmdline_add_flag_type) GetProcAddress(library, "gpr_cmdline_add_flag");
|
@@ -569,4 +579,4 @@ void grpc_rb_load_imports(HMODULE library) {
|
|
569
579
|
gpr_thd_join_import = (gpr_thd_join_type) GetProcAddress(library, "gpr_thd_join");
|
570
580
|
}
|
571
581
|
|
572
|
-
#endif /*
|
582
|
+
#endif /* GPR_WINDOWS */
|