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
4ee9bb06
Commit
4ee9bb06
authored
8 years ago
by
Craig Tiller
Browse files
Options
Downloads
Patches
Plain Diff
Fix race if connector is shutdown while connecting
parent
749ccd99
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/core/ext/transport/chttp2/client/chttp2_connector.c
+9
-1
9 additions, 1 deletion
src/core/ext/transport/chttp2/client/chttp2_connector.c
with
9 additions
and
1 deletion
src/core/ext/transport/chttp2/client/chttp2_connector.c
+
9
−
1
View file @
4ee9bb06
...
@@ -56,6 +56,7 @@ typedef struct {
...
@@ -56,6 +56,7 @@ typedef struct {
gpr_refcount
refs
;
gpr_refcount
refs
;
bool
shutdown
;
bool
shutdown
;
bool
connecting
;
char
*
server_name
;
char
*
server_name
;
grpc_chttp2_create_handshakers_func
create_handshakers
;
grpc_chttp2_create_handshakers_func
create_handshakers
;
...
@@ -103,7 +104,9 @@ static void chttp2_connector_shutdown(grpc_exec_ctx *exec_ctx,
...
@@ -103,7 +104,9 @@ static void chttp2_connector_shutdown(grpc_exec_ctx *exec_ctx,
}
}
// If handshaking is not yet in progress, shutdown the endpoint.
// If handshaking is not yet in progress, shutdown the endpoint.
// Otherwise, the handshaker will do this for us.
// Otherwise, the handshaker will do this for us.
if
(
c
->
endpoint
!=
NULL
)
grpc_endpoint_shutdown
(
exec_ctx
,
c
->
endpoint
);
if
(
!
c
->
connecting
&&
c
->
endpoint
!=
NULL
)
{
grpc_endpoint_shutdown
(
exec_ctx
,
c
->
endpoint
);
}
gpr_mu_unlock
(
&
c
->
mu
);
gpr_mu_unlock
(
&
c
->
mu
);
}
}
...
@@ -192,6 +195,8 @@ static void on_initial_connect_string_sent(grpc_exec_ctx *exec_ctx, void *arg,
...
@@ -192,6 +195,8 @@ static void on_initial_connect_string_sent(grpc_exec_ctx *exec_ctx, void *arg,
static
void
connected
(
grpc_exec_ctx
*
exec_ctx
,
void
*
arg
,
grpc_error
*
error
)
{
static
void
connected
(
grpc_exec_ctx
*
exec_ctx
,
void
*
arg
,
grpc_error
*
error
)
{
chttp2_connector
*
c
=
arg
;
chttp2_connector
*
c
=
arg
;
gpr_mu_lock
(
&
c
->
mu
);
gpr_mu_lock
(
&
c
->
mu
);
GPR_ASSERT
(
c
->
connecting
);
c
->
connecting
=
false
;
if
(
error
!=
GRPC_ERROR_NONE
||
c
->
shutdown
)
{
if
(
error
!=
GRPC_ERROR_NONE
||
c
->
shutdown
)
{
if
(
error
==
GRPC_ERROR_NONE
)
{
if
(
error
==
GRPC_ERROR_NONE
)
{
error
=
GRPC_ERROR_CREATE
(
"connector shutdown"
);
error
=
GRPC_ERROR_CREATE
(
"connector shutdown"
);
...
@@ -202,6 +207,7 @@ static void connected(grpc_exec_ctx *exec_ctx, void *arg, grpc_error *error) {
...
@@ -202,6 +207,7 @@ static void connected(grpc_exec_ctx *exec_ctx, void *arg, grpc_error *error) {
grpc_closure
*
notify
=
c
->
notify
;
grpc_closure
*
notify
=
c
->
notify
;
c
->
notify
=
NULL
;
c
->
notify
=
NULL
;
grpc_exec_ctx_sched
(
exec_ctx
,
notify
,
error
,
NULL
);
grpc_exec_ctx_sched
(
exec_ctx
,
notify
,
error
,
NULL
);
if
(
c
->
endpoint
!=
NULL
)
grpc_endpoint_shutdown
(
exec_ctx
,
c
->
endpoint
);
gpr_mu_unlock
(
&
c
->
mu
);
gpr_mu_unlock
(
&
c
->
mu
);
chttp2_connector_unref
(
exec_ctx
,
arg
);
chttp2_connector_unref
(
exec_ctx
,
arg
);
}
else
{
}
else
{
...
@@ -235,6 +241,8 @@ static void chttp2_connector_connect(grpc_exec_ctx *exec_ctx,
...
@@ -235,6 +241,8 @@ static void chttp2_connector_connect(grpc_exec_ctx *exec_ctx,
GPR_ASSERT
(
c
->
endpoint
==
NULL
);
GPR_ASSERT
(
c
->
endpoint
==
NULL
);
chttp2_connector_ref
(
con
);
// Ref taken for callback.
chttp2_connector_ref
(
con
);
// Ref taken for callback.
grpc_closure_init
(
&
c
->
connected
,
connected
,
c
);
grpc_closure_init
(
&
c
->
connected
,
connected
,
c
);
GPR_ASSERT
(
!
c
->
connecting
);
c
->
connecting
=
true
;
grpc_tcp_client_connect
(
exec_ctx
,
&
c
->
connected
,
&
c
->
endpoint
,
grpc_tcp_client_connect
(
exec_ctx
,
&
c
->
connected
,
&
c
->
endpoint
,
args
->
interested_parties
,
args
->
channel_args
,
args
->
interested_parties
,
args
->
channel_args
,
args
->
addr
,
args
->
deadline
);
args
->
addr
,
args
->
deadline
);
...
...
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