Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
G
Grpc
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container Registry
Model registry
Operate
Environments
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
tci-gateway-module
Grpc
Commits
d7455abf
Commit
d7455abf
authored
7 years ago
by
Alexander Polcyn
Browse files
Options
Downloads
Patches
Plain Diff
make get conn state always safe to call
parent
c24d53b0
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/ruby/end2end/multiple_killed_watching_threads_driver.rb
+7
-0
7 additions, 0 deletions
src/ruby/end2end/multiple_killed_watching_threads_driver.rb
src/ruby/ext/grpc/rb_channel.c
+4
-8
4 additions, 8 deletions
src/ruby/ext/grpc/rb_channel.c
with
11 additions
and
8 deletions
src/ruby/end2end/multiple_killed_watching_threads_driver.rb
+
7
−
0
View file @
d7455abf
...
@@ -46,10 +46,17 @@ def watch_state(ch)
...
@@ -46,10 +46,17 @@ def watch_state(ch)
end
end
def
main
def
main
channels
=
[]
10
.
times
do
10
.
times
do
ch
=
GRPC
::
Core
::
Channel
.
new
(
'dummy_host'
,
ch
=
GRPC
::
Core
::
Channel
.
new
(
'dummy_host'
,
nil
,
:this_channel_is_insecure
)
nil
,
:this_channel_is_insecure
)
watch_state
(
ch
)
watch_state
(
ch
)
channels
<<
ch
end
# checking state should still be safe to call
channels
.
each
do
|
c
|
fail
unless
c
.
connectivity_state
(
false
)
==
FATAL_FAILURE
end
end
end
end
...
...
This diff is collapsed.
Click to expand it.
src/ruby/ext/grpc/rb_channel.c
+
4
−
8
View file @
d7455abf
...
@@ -273,7 +273,7 @@ static VALUE grpc_rb_channel_init(int argc, VALUE *argv, VALUE self) {
...
@@ -273,7 +273,7 @@ static VALUE grpc_rb_channel_init(int argc, VALUE *argv, VALUE self) {
}
}
typedef
struct
get_state_stack
{
typedef
struct
get_state_stack
{
grpc
_channel
*
channel
;
bg_watched
_channel
*
bg
;
int
try_to_connect
;
int
try_to_connect
;
int
out
;
int
out
;
}
get_state_stack
;
}
get_state_stack
;
...
@@ -283,14 +283,10 @@ static void *get_state_without_gil(void *arg) {
...
@@ -283,14 +283,10 @@ static void *get_state_without_gil(void *arg) {
gpr_mu_lock
(
&
global_connection_polling_mu
);
gpr_mu_lock
(
&
global_connection_polling_mu
);
GPR_ASSERT
(
abort_channel_polling
||
channel_polling_thread_started
);
GPR_ASSERT
(
abort_channel_polling
||
channel_polling_thread_started
);
if
(
abort_channel_polling
)
{
if
(
stack
->
bg
->
channel_destroyed
)
{
// Assume that this channel has been destroyed by the
// background thread.
// The case in which the channel polling thread
// failed to start just always shows shutdown state.
stack
->
out
=
GRPC_CHANNEL_SHUTDOWN
;
stack
->
out
=
GRPC_CHANNEL_SHUTDOWN
;
}
else
{
}
else
{
stack
->
out
=
grpc_channel_check_connectivity_state
(
stack
->
channel
,
stack
->
out
=
grpc_channel_check_connectivity_state
(
stack
->
bg
->
channel
,
stack
->
try_to_connect
);
stack
->
try_to_connect
);
}
}
gpr_mu_unlock
(
&
global_connection_polling_mu
);
gpr_mu_unlock
(
&
global_connection_polling_mu
);
...
@@ -322,7 +318,7 @@ static VALUE grpc_rb_channel_get_connectivity_state(int argc, VALUE *argv,
...
@@ -322,7 +318,7 @@ static VALUE grpc_rb_channel_get_connectivity_state(int argc, VALUE *argv,
return
Qnil
;
return
Qnil
;
}
}
stack
.
channel
=
wrapper
->
bg_wrapped
->
channel
;
stack
.
bg
=
wrapper
->
bg_wrapped
;
stack
.
try_to_connect
=
RTEST
(
try_to_connect_param
)
?
1
:
0
;
stack
.
try_to_connect
=
RTEST
(
try_to_connect_param
)
?
1
:
0
;
rb_thread_call_without_gvl
(
get_state_without_gil
,
&
stack
,
NULL
,
NULL
);
rb_thread_call_without_gvl
(
get_state_without_gil
,
&
stack
,
NULL
,
NULL
);
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment