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
bd913a86
Commit
bd913a86
authored
8 years ago
by
Mark D. Roth
Browse files
Options
Downloads
Patches
Plain Diff
Fix asan failures.
parent
a5617850
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/core/lib/http/httpcli_security_connector.c
+10
-25
10 additions, 25 deletions
src/core/lib/http/httpcli_security_connector.c
src/core/lib/security/transport/security_handshaker.c
+2
-2
2 additions, 2 deletions
src/core/lib/security/transport/security_handshaker.c
with
12 additions
and
27 deletions
src/core/lib/http/httpcli_security_connector.c
+
10
−
25
View file @
bd913a86
...
@@ -47,26 +47,17 @@
...
@@ -47,26 +47,17 @@
typedef
struct
{
typedef
struct
{
grpc_channel_security_connector
base
;
grpc_channel_security_connector
base
;
tsi_ssl_handshaker_factory
*
handshaker_factory
;
tsi_ssl_handshaker_factory
*
handshaker_factory
;
grpc_handshake_manager
*
handshake_mgr
;
char
*
secure_peer_name
;
char
*
secure_peer_name
;
}
grpc_httpcli_ssl_channel_security_connector
;
}
grpc_httpcli_ssl_channel_security_connector
;
static
void
httpcli_ssl_destroy
(
grpc_security_connector
*
sc
)
{
static
void
httpcli_ssl_destroy
(
grpc_security_connector
*
sc
)
{
// TODO(roth, ctiller): Once https://github.com/grpc/grpc/pull/8705 is
// merged, change this to use the passed-in exec_ctx instead of creating
// its own.
grpc_exec_ctx
exec_ctx
=
GRPC_EXEC_CTX_INIT
;
grpc_httpcli_ssl_channel_security_connector
*
c
=
grpc_httpcli_ssl_channel_security_connector
*
c
=
(
grpc_httpcli_ssl_channel_security_connector
*
)
sc
;
(
grpc_httpcli_ssl_channel_security_connector
*
)
sc
;
if
(
c
->
handshaker_factory
!=
NULL
)
{
if
(
c
->
handshaker_factory
!=
NULL
)
{
tsi_ssl_handshaker_factory_destroy
(
c
->
handshaker_factory
);
tsi_ssl_handshaker_factory_destroy
(
c
->
handshaker_factory
);
}
}
if
(
c
->
handshake_mgr
!=
NULL
)
{
grpc_handshake_manager_destroy
(
&
exec_ctx
,
c
->
handshake_mgr
);
}
if
(
c
->
secure_peer_name
!=
NULL
)
gpr_free
(
c
->
secure_peer_name
);
if
(
c
->
secure_peer_name
!=
NULL
)
gpr_free
(
c
->
secure_peer_name
);
gpr_free
(
sc
);
gpr_free
(
sc
);
grpc_exec_ctx_finish
(
&
exec_ctx
);
}
}
static
void
httpcli_ssl_create_handshakers
(
static
void
httpcli_ssl_create_handshakers
(
...
@@ -141,7 +132,6 @@ static grpc_security_status httpcli_ssl_channel_security_connector_create(
...
@@ -141,7 +132,6 @@ static grpc_security_status httpcli_ssl_channel_security_connector_create(
*
sc
=
NULL
;
*
sc
=
NULL
;
return
GRPC_SECURITY_ERROR
;
return
GRPC_SECURITY_ERROR
;
}
}
c
->
handshake_mgr
=
grpc_handshake_manager_create
();
c
->
base
.
create_handshakers
=
httpcli_ssl_create_handshakers
;
c
->
base
.
create_handshakers
=
httpcli_ssl_create_handshakers
;
*
sc
=
&
c
->
base
;
*
sc
=
&
c
->
base
;
return
GRPC_SECURITY_OK
;
return
GRPC_SECURITY_OK
;
...
@@ -152,29 +142,25 @@ static grpc_security_status httpcli_ssl_channel_security_connector_create(
...
@@ -152,29 +142,25 @@ static grpc_security_status httpcli_ssl_channel_security_connector_create(
typedef
struct
{
typedef
struct
{
void
(
*
func
)(
grpc_exec_ctx
*
exec_ctx
,
void
*
arg
,
grpc_endpoint
*
endpoint
);
void
(
*
func
)(
grpc_exec_ctx
*
exec_ctx
,
void
*
arg
,
grpc_endpoint
*
endpoint
);
void
*
arg
;
void
*
arg
;
grpc_handshake_manager
*
handshake_mgr
;
}
on_done_closure
;
}
on_done_closure
;
static
void
on_handshake_done
(
grpc_exec_ctx
*
exec_ctx
,
void
*
arg
,
static
void
on_handshake_done
(
grpc_exec_ctx
*
exec_ctx
,
void
*
arg
,
grpc_error
*
error
)
{
grpc_error
*
error
)
{
grpc_handshaker_args
*
args
=
arg
;
grpc_handshaker_args
*
args
=
arg
;
on_done_closure
*
c
=
args
->
user_data
;
on_done_closure
*
c
=
args
->
user_data
;
grpc_channel_args_destroy
(
args
->
args
);
grpc_slice_buffer_destroy
(
args
->
read_buffer
);
gpr_free
(
args
->
read_buffer
);
if
(
error
!=
GRPC_ERROR_NONE
)
{
if
(
error
!=
GRPC_ERROR_NONE
)
{
const
char
*
msg
=
grpc_error_string
(
error
);
const
char
*
msg
=
grpc_error_string
(
error
);
gpr_log
(
GPR_ERROR
,
"Secure transport setup failed: %s"
,
msg
);
gpr_log
(
GPR_ERROR
,
"Secure transport setup failed: %s"
,
msg
);
grpc_error_free_string
(
msg
);
grpc_error_free_string
(
msg
);
c
->
func
(
exec_ctx
,
c
->
arg
,
NULL
);
c
->
func
(
exec_ctx
,
c
->
arg
,
NULL
);
// TODO(ctiller): It is currently necessary to shutdown endpoints
// before destroying them, even if we know that there are no
// pending read/write callbacks. This should be fixed, at which
// point this can be removed.
grpc_endpoint_shutdown
(
exec_ctx
,
args
->
endpoint
);
grpc_endpoint_destroy
(
exec_ctx
,
args
->
endpoint
);
}
else
{
}
else
{
grpc_channel_args_destroy
(
args
->
args
);
grpc_slice_buffer_destroy
(
args
->
read_buffer
);
gpr_free
(
args
->
read_buffer
);
c
->
func
(
exec_ctx
,
c
->
arg
,
args
->
endpoint
);
c
->
func
(
exec_ctx
,
c
->
arg
,
args
->
endpoint
);
}
}
grpc_handshake_manager_destroy
(
exec_ctx
,
c
->
handshake_mgr
);
gpr_free
(
c
);
gpr_free
(
c
);
}
}
...
@@ -195,16 +181,15 @@ static void ssl_handshake(grpc_exec_ctx *exec_ctx, void *arg,
...
@@ -195,16 +181,15 @@ static void ssl_handshake(grpc_exec_ctx *exec_ctx, void *arg,
}
}
c
->
func
=
on_done
;
c
->
func
=
on_done
;
c
->
arg
=
arg
;
c
->
arg
=
arg
;
c
->
handshake_mgr
=
grpc_handshake_manager_create
();
GPR_ASSERT
(
httpcli_ssl_channel_security_connector_create
(
GPR_ASSERT
(
httpcli_ssl_channel_security_connector_create
(
pem_root_certs
,
pem_root_certs_size
,
host
,
&
sc
)
==
pem_root_certs
,
pem_root_certs_size
,
host
,
&
sc
)
==
GRPC_SECURITY_OK
);
GRPC_SECURITY_OK
);
grpc_httpcli_ssl_channel_security_connector
*
httpcli_connector
=
grpc_channel_security_connector_create_handshakers
(
exec_ctx
,
sc
,
(
grpc_httpcli_ssl_channel_security_connector
*
)
sc
;
c
->
handshake_mgr
);
grpc_channel_security_connector_create_handshakers
(
exec_ctx
,
sc
,
httpcli_connector
->
handshake_mgr
);
grpc_handshake_manager_do_handshake
(
grpc_handshake_manager_do_handshake
(
exec_ctx
,
httpcli_connector
->
handshake_mgr
,
tcp
,
NULL
/* channel_args */
,
exec_ctx
,
c
->
handshake_mgr
,
tcp
,
NULL
/* channel_args */
,
deadline
,
deadline
,
NULL
/* acceptor */
,
on_handshake_done
,
c
/* user_data */
);
NULL
/* acceptor */
,
on_handshake_done
,
c
/* user_data */
);
GRPC_SECURITY_CONNECTOR_UNREF
(
&
sc
->
base
,
"httpcli"
);
GRPC_SECURITY_CONNECTOR_UNREF
(
&
sc
->
base
,
"httpcli"
);
}
}
...
...
This diff is collapsed.
Click to expand it.
src/core/lib/security/transport/security_handshaker.c
+
2
−
2
View file @
bd913a86
...
@@ -81,8 +81,7 @@ static void security_handshaker_unref(grpc_exec_ctx *exec_ctx,
...
@@ -81,8 +81,7 @@ static void security_handshaker_unref(grpc_exec_ctx *exec_ctx,
security_handshaker
*
h
)
{
security_handshaker
*
h
)
{
if
(
gpr_unref
(
&
h
->
refs
))
{
if
(
gpr_unref
(
&
h
->
refs
))
{
gpr_mu_destroy
(
&
h
->
mu
);
gpr_mu_destroy
(
&
h
->
mu
);
if
(
h
->
handshaker
!=
NULL
)
tsi_handshaker_destroy
(
h
->
handshaker
);
tsi_handshaker_destroy
(
h
->
handshaker
);
if
(
h
->
handshake_buffer
!=
NULL
)
gpr_free
(
h
->
handshake_buffer
);
if
(
h
->
endpoint_to_destroy
!=
NULL
)
{
if
(
h
->
endpoint_to_destroy
!=
NULL
)
{
grpc_endpoint_destroy
(
exec_ctx
,
h
->
endpoint_to_destroy
);
grpc_endpoint_destroy
(
exec_ctx
,
h
->
endpoint_to_destroy
);
}
}
...
@@ -90,6 +89,7 @@ static void security_handshaker_unref(grpc_exec_ctx *exec_ctx,
...
@@ -90,6 +89,7 @@ static void security_handshaker_unref(grpc_exec_ctx *exec_ctx,
grpc_slice_buffer_destroy
(
h
->
read_buffer_to_destroy
);
grpc_slice_buffer_destroy
(
h
->
read_buffer_to_destroy
);
gpr_free
(
h
->
read_buffer_to_destroy
);
gpr_free
(
h
->
read_buffer_to_destroy
);
}
}
gpr_free
(
h
->
handshake_buffer
);
grpc_slice_buffer_destroy
(
&
h
->
left_overs
);
grpc_slice_buffer_destroy
(
&
h
->
left_overs
);
grpc_slice_buffer_destroy
(
&
h
->
outgoing
);
grpc_slice_buffer_destroy
(
&
h
->
outgoing
);
GRPC_AUTH_CONTEXT_UNREF
(
h
->
auth_context
,
"handshake"
);
GRPC_AUTH_CONTEXT_UNREF
(
h
->
auth_context
,
"handshake"
);
...
...
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