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
dcdec3c3
Commit
dcdec3c3
authored
10 years ago
by
David Klempner
Browse files
Options
Downloads
Plain Diff
Merge pull request #553 from ctiller/tsan
Fix a race in transport.
parents
28fa2625
1fe7b9d6
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/core/transport/chttp2_transport.c
+11
-0
11 additions, 0 deletions
src/core/transport/chttp2_transport.c
with
11 additions
and
0 deletions
src/core/transport/chttp2_transport.c
+
11
−
0
View file @
dcdec3c3
...
@@ -184,11 +184,13 @@ struct transport {
...
@@ -184,11 +184,13 @@ struct transport {
gpr_uint8
is_client
;
gpr_uint8
is_client
;
gpr_mu
mu
;
gpr_mu
mu
;
gpr_cv
cv
;
/* basic state management - what are we doing at the moment? */
/* basic state management - what are we doing at the moment? */
gpr_uint8
reading
;
gpr_uint8
reading
;
gpr_uint8
writing
;
gpr_uint8
writing
;
gpr_uint8
calling_back
;
gpr_uint8
calling_back
;
gpr_uint8
destroying
;
error_state
error_state
;
error_state
error_state
;
/* stream indexing */
/* stream indexing */
...
@@ -362,6 +364,7 @@ static void unref_transport(transport *t) {
...
@@ -362,6 +364,7 @@ static void unref_transport(transport *t) {
gpr_mu_unlock
(
&
t
->
mu
);
gpr_mu_unlock
(
&
t
->
mu
);
gpr_mu_destroy
(
&
t
->
mu
);
gpr_mu_destroy
(
&
t
->
mu
);
gpr_cv_destroy
(
&
t
->
cv
);
/* callback remaining pings: they're not allowed to call into the transpot,
/* callback remaining pings: they're not allowed to call into the transpot,
and maybe they hold resources that need to be freed */
and maybe they hold resources that need to be freed */
...
@@ -397,6 +400,7 @@ static void init_transport(transport *t, grpc_transport_setup_callback setup,
...
@@ -397,6 +400,7 @@ static void init_transport(transport *t, grpc_transport_setup_callback setup,
/* one ref is for destroy, the other for when ep becomes NULL */
/* one ref is for destroy, the other for when ep becomes NULL */
gpr_ref_init
(
&
t
->
refs
,
2
);
gpr_ref_init
(
&
t
->
refs
,
2
);
gpr_mu_init
(
&
t
->
mu
);
gpr_mu_init
(
&
t
->
mu
);
gpr_cv_init
(
&
t
->
cv
);
t
->
metadata_context
=
mdctx
;
t
->
metadata_context
=
mdctx
;
t
->
str_grpc_timeout
=
t
->
str_grpc_timeout
=
grpc_mdstr_from_string
(
t
->
metadata_context
,
"grpc-timeout"
);
grpc_mdstr_from_string
(
t
->
metadata_context
,
"grpc-timeout"
);
...
@@ -405,6 +409,7 @@ static void init_transport(transport *t, grpc_transport_setup_callback setup,
...
@@ -405,6 +409,7 @@ static void init_transport(transport *t, grpc_transport_setup_callback setup,
t
->
error_state
=
ERROR_STATE_NONE
;
t
->
error_state
=
ERROR_STATE_NONE
;
t
->
next_stream_id
=
is_client
?
1
:
2
;
t
->
next_stream_id
=
is_client
?
1
:
2
;
t
->
last_incoming_stream_id
=
0
;
t
->
last_incoming_stream_id
=
0
;
t
->
destroying
=
0
;
t
->
is_client
=
is_client
;
t
->
is_client
=
is_client
;
t
->
outgoing_window
=
DEFAULT_WINDOW
;
t
->
outgoing_window
=
DEFAULT_WINDOW
;
t
->
incoming_window
=
DEFAULT_WINDOW
;
t
->
incoming_window
=
DEFAULT_WINDOW
;
...
@@ -487,6 +492,7 @@ static void init_transport(transport *t, grpc_transport_setup_callback setup,
...
@@ -487,6 +492,7 @@ static void init_transport(transport *t, grpc_transport_setup_callback setup,
t
->
cb
=
sr
.
callbacks
;
t
->
cb
=
sr
.
callbacks
;
t
->
cb_user_data
=
sr
.
user_data
;
t
->
cb_user_data
=
sr
.
user_data
;
t
->
calling_back
=
0
;
t
->
calling_back
=
0
;
if
(
t
->
destroying
)
gpr_cv_signal
(
&
t
->
cv
);
unlock
(
t
);
unlock
(
t
);
unref_transport
(
t
);
unref_transport
(
t
);
}
}
...
@@ -495,6 +501,10 @@ static void destroy_transport(grpc_transport *gt) {
...
@@ -495,6 +501,10 @@ static void destroy_transport(grpc_transport *gt) {
transport
*
t
=
(
transport
*
)
gt
;
transport
*
t
=
(
transport
*
)
gt
;
gpr_mu_lock
(
&
t
->
mu
);
gpr_mu_lock
(
&
t
->
mu
);
t
->
destroying
=
1
;
while
(
t
->
calling_back
)
{
gpr_cv_wait
(
&
t
->
cv
,
&
t
->
mu
,
gpr_inf_future
);
}
t
->
cb
=
NULL
;
t
->
cb
=
NULL
;
gpr_mu_unlock
(
&
t
->
mu
);
gpr_mu_unlock
(
&
t
->
mu
);
...
@@ -754,6 +764,7 @@ static void unlock(transport *t) {
...
@@ -754,6 +764,7 @@ static void unlock(transport *t) {
if
(
perform_callbacks
||
call_closed
||
num_goaways
)
{
if
(
perform_callbacks
||
call_closed
||
num_goaways
)
{
lock
(
t
);
lock
(
t
);
t
->
calling_back
=
0
;
t
->
calling_back
=
0
;
if
(
t
->
destroying
)
gpr_cv_signal
(
&
t
->
cv
);
unlock
(
t
);
unlock
(
t
);
unref_transport
(
t
);
unref_transport
(
t
);
}
}
...
...
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