grpc 1.9.0.pre1 → 1.9.0.pre2
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/Makefile +3 -3
- data/src/core/ext/filters/max_age/max_age_filter.cc +159 -21
- data/src/core/lib/surface/version.cc +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
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b727fc38e0b40853ad0d7066f43e890329d3e71f6ca709299ca8c70e960e2a12
|
4
|
+
data.tar.gz: 5647639c196148ba184ff497cacaf6e985bab50127cf0f5134edc4b01bbd6c4b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c416db0869ce536011ed2f16ad0197297ea6cf5f2d8ea21b3405b5f46115a7097f8ba410af093b2780050f3cef91062422266d1efb6249f8c9d16f38c6063ff1
|
7
|
+
data.tar.gz: 8665dca460ebf3d8b6ca61b353e317aff12e0038e32416817a0321fe5823e4196f6ee0ea3a32e4b95227b629e7c90cb6e3f0647665168147d3580d7e1e6e6526
|
data/Makefile
CHANGED
@@ -418,9 +418,9 @@ E = @echo
|
|
418
418
|
Q = @
|
419
419
|
endif
|
420
420
|
|
421
|
-
CORE_VERSION = 5.0.0-
|
422
|
-
CPP_VERSION = 1.9.0-
|
423
|
-
CSHARP_VERSION = 1.9.0-
|
421
|
+
CORE_VERSION = 5.0.0-pre2
|
422
|
+
CPP_VERSION = 1.9.0-pre2
|
423
|
+
CSHARP_VERSION = 1.9.0-pre2
|
424
424
|
|
425
425
|
CPPFLAGS_NO_ARCH += $(addprefix -I, $(INCLUDES)) $(addprefix -D, $(DEFINES))
|
426
426
|
CPPFLAGS += $(CPPFLAGS_NO_ARCH) $(ARCH_FLAGS)
|
@@ -37,6 +37,12 @@
|
|
37
37
|
#define MAX_CONNECTION_IDLE_INTEGER_OPTIONS \
|
38
38
|
{ DEFAULT_MAX_CONNECTION_IDLE_MS, 1, INT_MAX }
|
39
39
|
|
40
|
+
/* States for idle_state in channel_data */
|
41
|
+
#define MAX_IDLE_STATE_INIT ((gpr_atm)0)
|
42
|
+
#define MAX_IDLE_STATE_SEEN_EXIT_IDLE ((gpr_atm)1)
|
43
|
+
#define MAX_IDLE_STATE_SEEN_ENTER_IDLE ((gpr_atm)2)
|
44
|
+
#define MAX_IDLE_STATE_TIMER_SET ((gpr_atm)3)
|
45
|
+
|
40
46
|
namespace {
|
41
47
|
struct channel_data {
|
42
48
|
/* We take a reference to the channel stack for the timer callback */
|
@@ -64,7 +70,7 @@ struct channel_data {
|
|
64
70
|
grpc_millis max_connection_age_grace;
|
65
71
|
/* Closure to run when the channel's idle duration reaches max_connection_idle
|
66
72
|
and should be closed gracefully */
|
67
|
-
grpc_closure
|
73
|
+
grpc_closure max_idle_timer_cb;
|
68
74
|
/* Closure to run when the channel reaches its max age and should be closed
|
69
75
|
gracefully */
|
70
76
|
grpc_closure close_max_age_channel;
|
@@ -85,26 +91,117 @@ struct channel_data {
|
|
85
91
|
grpc_connectivity_state connectivity_state;
|
86
92
|
/* Number of active calls */
|
87
93
|
gpr_atm call_count;
|
94
|
+
/* TODO(zyc): C++lize this state machine */
|
95
|
+
/* 'idle_state' holds the states of max_idle_timer and channel idleness.
|
96
|
+
It can contain one of the following values:
|
97
|
+
+--------------------------------+----------------+---------+
|
98
|
+
| idle_state | max_idle_timer | channel |
|
99
|
+
+--------------------------------+----------------+---------+
|
100
|
+
| MAX_IDLE_STATE_INIT | unset | busy |
|
101
|
+
| MAX_IDLE_STATE_TIMER_SET | set, valid | idle |
|
102
|
+
| MAX_IDLE_STATE_SEEN_EXIT_IDLE | set, invalid | busy |
|
103
|
+
| MAX_IDLE_STATE_SEEN_ENTER_IDLE | set, invalid | idle |
|
104
|
+
+--------------------------------+----------------+---------+
|
105
|
+
|
106
|
+
MAX_IDLE_STATE_INIT: The initial and final state of 'idle_state'. The
|
107
|
+
channel has 1 or 1+ active calls, and the the timer is not set. Note that
|
108
|
+
we may put a virtual call to hold this state at channel initialization or
|
109
|
+
shutdown, so that the channel won't enter other states.
|
110
|
+
|
111
|
+
MAX_IDLE_STATE_TIMER_SET: The state after the timer is set and no calls
|
112
|
+
have arrived after the timer is set. The channel must have 0 active call in
|
113
|
+
this state. If the timer is fired in this state, we will close the channel
|
114
|
+
due to idleness.
|
115
|
+
|
116
|
+
MAX_IDLE_STATE_SEEN_EXIT_IDLE: The state after the timer is set and at
|
117
|
+
least one call has arrived after the timer is set. The channel must have 1
|
118
|
+
or 1+ active calls in this state. If the timer is fired in this state, we
|
119
|
+
won't reschudle it.
|
120
|
+
|
121
|
+
MAX_IDLE_STATE_SEEN_ENTER_IDLE: The state after the timer is set and the at
|
122
|
+
least one call has arrived after the timer is set, BUT the channel
|
123
|
+
currently has 1 or 1+ active calls. If the timer is fired in this state, we
|
124
|
+
will reschudle it.
|
125
|
+
|
126
|
+
max_idle_timer will not be cancelled (unless the channel is shutting down).
|
127
|
+
If the timer callback is called when the max_idle_timer is valid (i.e.
|
128
|
+
idle_state is MAX_IDLE_STATE_TIMER_SET), the channel will be closed due to
|
129
|
+
idleness, otherwise the channel won't be changed.
|
130
|
+
|
131
|
+
State transitions:
|
132
|
+
MAX_IDLE_STATE_INIT <-------3------ MAX_IDLE_STATE_SEEN_EXIT_IDLE
|
133
|
+
^ | ^ ^ |
|
134
|
+
| | | | |
|
135
|
+
1 2 +-----------4------------+ 6 7
|
136
|
+
| | | | |
|
137
|
+
| v | | v
|
138
|
+
MAX_IDLE_STATE_TIMER_SET <----5------ MAX_IDLE_STATE_SEEN_ENTER_IDLE
|
139
|
+
|
140
|
+
For 1, 3, 5 : See max_idle_timer_cb() function
|
141
|
+
For 2, 7 : See decrease_call_count() function
|
142
|
+
For 4, 6 : See increase_call_count() function */
|
143
|
+
gpr_atm idle_state;
|
144
|
+
/* Time when the channel finished its last outstanding call, in grpc_millis */
|
145
|
+
gpr_atm last_enter_idle_time_millis;
|
88
146
|
};
|
89
147
|
} // namespace
|
90
148
|
|
91
149
|
/* Increase the nubmer of active calls. Before the increasement, if there are no
|
92
150
|
calls, the max_idle_timer should be cancelled. */
|
93
151
|
static void increase_call_count(channel_data* chand) {
|
152
|
+
/* Exit idle */
|
94
153
|
if (gpr_atm_full_fetch_add(&chand->call_count, 1) == 0) {
|
95
|
-
|
154
|
+
while (true) {
|
155
|
+
gpr_atm idle_state = gpr_atm_acq_load(&chand->idle_state);
|
156
|
+
switch (idle_state) {
|
157
|
+
case MAX_IDLE_STATE_TIMER_SET:
|
158
|
+
/* max_idle_timer_cb may have already set idle_state to
|
159
|
+
MAX_IDLE_STATE_INIT, in this case, we don't need to set it to
|
160
|
+
MAX_IDLE_STATE_SEEN_EXIT_IDLE */
|
161
|
+
gpr_atm_rel_cas(&chand->idle_state, MAX_IDLE_STATE_TIMER_SET,
|
162
|
+
MAX_IDLE_STATE_SEEN_EXIT_IDLE);
|
163
|
+
return;
|
164
|
+
case MAX_IDLE_STATE_SEEN_ENTER_IDLE:
|
165
|
+
gpr_atm_rel_store(&chand->idle_state, MAX_IDLE_STATE_SEEN_EXIT_IDLE);
|
166
|
+
return;
|
167
|
+
default:
|
168
|
+
/* try again */
|
169
|
+
break;
|
170
|
+
}
|
171
|
+
}
|
96
172
|
}
|
97
173
|
}
|
98
174
|
|
99
175
|
/* Decrease the nubmer of active calls. After the decrement, if there are no
|
100
176
|
calls, the max_idle_timer should be started. */
|
101
177
|
static void decrease_call_count(channel_data* chand) {
|
178
|
+
/* Enter idle */
|
102
179
|
if (gpr_atm_full_fetch_add(&chand->call_count, -1) == 1) {
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
180
|
+
gpr_atm_no_barrier_store(&chand->last_enter_idle_time_millis,
|
181
|
+
(gpr_atm)grpc_core::ExecCtx::Get()->Now());
|
182
|
+
while (true) {
|
183
|
+
gpr_atm idle_state = gpr_atm_acq_load(&chand->idle_state);
|
184
|
+
switch (idle_state) {
|
185
|
+
case MAX_IDLE_STATE_INIT:
|
186
|
+
GRPC_CHANNEL_STACK_REF(chand->channel_stack,
|
187
|
+
"max_age max_idle_timer");
|
188
|
+
grpc_timer_init(
|
189
|
+
&chand->max_idle_timer,
|
190
|
+
grpc_core::ExecCtx::Get()->Now() + chand->max_connection_idle,
|
191
|
+
&chand->max_idle_timer_cb);
|
192
|
+
gpr_atm_rel_store(&chand->idle_state, MAX_IDLE_STATE_TIMER_SET);
|
193
|
+
return;
|
194
|
+
case MAX_IDLE_STATE_SEEN_EXIT_IDLE:
|
195
|
+
if (gpr_atm_rel_cas(&chand->idle_state, MAX_IDLE_STATE_SEEN_EXIT_IDLE,
|
196
|
+
MAX_IDLE_STATE_SEEN_ENTER_IDLE)) {
|
197
|
+
return;
|
198
|
+
}
|
199
|
+
break;
|
200
|
+
default:
|
201
|
+
/* try again */
|
202
|
+
break;
|
203
|
+
}
|
204
|
+
}
|
108
205
|
}
|
109
206
|
}
|
110
207
|
|
@@ -152,20 +249,58 @@ static void start_max_age_grace_timer_after_goaway_op(void* arg,
|
|
152
249
|
"max_age start_max_age_grace_timer_after_goaway_op");
|
153
250
|
}
|
154
251
|
|
155
|
-
static void close_max_idle_channel(
|
252
|
+
static void close_max_idle_channel(channel_data* chand) {
|
253
|
+
/* Prevent the max idle timer from being set again */
|
254
|
+
gpr_atm_no_barrier_fetch_add(&chand->call_count, 1);
|
255
|
+
grpc_transport_op* op = grpc_make_transport_op(nullptr);
|
256
|
+
op->goaway_error =
|
257
|
+
grpc_error_set_int(GRPC_ERROR_CREATE_FROM_STATIC_STRING("max_idle"),
|
258
|
+
GRPC_ERROR_INT_HTTP2_ERROR, GRPC_HTTP2_NO_ERROR);
|
259
|
+
grpc_channel_element* elem =
|
260
|
+
grpc_channel_stack_element(chand->channel_stack, 0);
|
261
|
+
elem->filter->start_transport_op(elem, op);
|
262
|
+
}
|
263
|
+
|
264
|
+
static void max_idle_timer_cb(void* arg, grpc_error* error) {
|
156
265
|
channel_data* chand = (channel_data*)arg;
|
157
266
|
if (error == GRPC_ERROR_NONE) {
|
158
|
-
|
159
|
-
|
160
|
-
|
161
|
-
|
162
|
-
|
163
|
-
|
164
|
-
|
165
|
-
|
166
|
-
|
167
|
-
|
168
|
-
|
267
|
+
bool try_again = true;
|
268
|
+
while (try_again) {
|
269
|
+
gpr_atm idle_state = gpr_atm_acq_load(&chand->idle_state);
|
270
|
+
switch (idle_state) {
|
271
|
+
case MAX_IDLE_STATE_TIMER_SET:
|
272
|
+
close_max_idle_channel(chand);
|
273
|
+
/* This MAX_IDLE_STATE_INIT is a final state, we don't have to check
|
274
|
+
* if idle_state has been changed */
|
275
|
+
gpr_atm_rel_store(&chand->idle_state, MAX_IDLE_STATE_INIT);
|
276
|
+
try_again = false;
|
277
|
+
break;
|
278
|
+
case MAX_IDLE_STATE_SEEN_EXIT_IDLE:
|
279
|
+
if (gpr_atm_rel_cas(&chand->idle_state, MAX_IDLE_STATE_SEEN_EXIT_IDLE,
|
280
|
+
MAX_IDLE_STATE_INIT)) {
|
281
|
+
try_again = false;
|
282
|
+
}
|
283
|
+
break;
|
284
|
+
case MAX_IDLE_STATE_SEEN_ENTER_IDLE:
|
285
|
+
GRPC_CHANNEL_STACK_REF(chand->channel_stack,
|
286
|
+
"max_age max_idle_timer");
|
287
|
+
grpc_timer_init(&chand->max_idle_timer,
|
288
|
+
(grpc_millis)gpr_atm_no_barrier_load(
|
289
|
+
&chand->last_enter_idle_time_millis) +
|
290
|
+
chand->max_connection_idle,
|
291
|
+
&chand->max_idle_timer_cb);
|
292
|
+
/* idle_state may have already been set to
|
293
|
+
MAX_IDLE_STATE_SEEN_EXIT_IDLE by increase_call_count(), in this
|
294
|
+
case, we don't need to set it to MAX_IDLE_STATE_TIMER_SET */
|
295
|
+
gpr_atm_rel_cas(&chand->idle_state, MAX_IDLE_STATE_SEEN_ENTER_IDLE,
|
296
|
+
MAX_IDLE_STATE_TIMER_SET);
|
297
|
+
try_again = false;
|
298
|
+
break;
|
299
|
+
default:
|
300
|
+
/* try again */
|
301
|
+
break;
|
302
|
+
}
|
303
|
+
}
|
169
304
|
}
|
170
305
|
GRPC_CHANNEL_STACK_UNREF(chand->channel_stack, "max_age max_idle_timer");
|
171
306
|
}
|
@@ -288,6 +423,9 @@ static grpc_error* init_channel_elem(grpc_channel_element* elem,
|
|
288
423
|
chand->max_connection_idle = DEFAULT_MAX_CONNECTION_IDLE_MS == INT_MAX
|
289
424
|
? GRPC_MILLIS_INF_FUTURE
|
290
425
|
: DEFAULT_MAX_CONNECTION_IDLE_MS;
|
426
|
+
chand->idle_state = MAX_IDLE_STATE_INIT;
|
427
|
+
gpr_atm_no_barrier_store(&chand->last_enter_idle_time_millis,
|
428
|
+
GRPC_MILLIS_INF_PAST);
|
291
429
|
for (size_t i = 0; i < args->channel_args->num_args; ++i) {
|
292
430
|
if (0 == strcmp(args->channel_args->args[i].key,
|
293
431
|
GRPC_ARG_MAX_CONNECTION_AGE_MS)) {
|
@@ -311,8 +449,8 @@ static grpc_error* init_channel_elem(grpc_channel_element* elem,
|
|
311
449
|
value == INT_MAX ? GRPC_MILLIS_INF_FUTURE : value;
|
312
450
|
}
|
313
451
|
}
|
314
|
-
GRPC_CLOSURE_INIT(&chand->
|
315
|
-
|
452
|
+
GRPC_CLOSURE_INIT(&chand->max_idle_timer_cb, max_idle_timer_cb, chand,
|
453
|
+
grpc_schedule_on_exec_ctx);
|
316
454
|
GRPC_CLOSURE_INIT(&chand->close_max_age_channel, close_max_age_channel, chand,
|
317
455
|
grpc_schedule_on_exec_ctx);
|
318
456
|
GRPC_CLOSURE_INIT(&chand->force_close_max_age_channel,
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: grpc
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.9.0.
|
4
|
+
version: 1.9.0.pre2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- gRPC Authors
|
8
8
|
autorequire:
|
9
9
|
bindir: src/ruby/bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2018-01-
|
11
|
+
date: 2018-01-24 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: google-protobuf
|