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
a92a13c4
Commit
a92a13c4
authored
8 years ago
by
Harvey Tuch
Browse files
Options
Downloads
Patches
Plain Diff
Fix server_ssl.c thread race exposed by tsan by using gpr_event.
parent
27c876ec
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
test/core/handshake/server_ssl.c
+5
-4
5 additions, 4 deletions
test/core/handshake/server_ssl.c
with
5 additions
and
4 deletions
test/core/handshake/server_ssl.c
+
5
−
4
View file @
a92a13c4
...
@@ -43,6 +43,7 @@
...
@@ -43,6 +43,7 @@
#include
<grpc/support/alloc.h>
#include
<grpc/support/alloc.h>
#include
<grpc/support/log.h>
#include
<grpc/support/log.h>
#include
<grpc/support/string_util.h>
#include
<grpc/support/string_util.h>
#include
<grpc/support/sync.h>
#include
<grpc/support/thd.h>
#include
<grpc/support/thd.h>
#include
"src/core/lib/iomgr/load_file.h"
#include
"src/core/lib/iomgr/load_file.h"
#include
"test/core/util/port.h"
#include
"test/core/util/port.h"
...
@@ -53,7 +54,7 @@
...
@@ -53,7 +54,7 @@
#define SSL_CA_PATH "src/core/lib/tsi/test_creds/ca.pem"
#define SSL_CA_PATH "src/core/lib/tsi/test_creds/ca.pem"
// Handshake completed signal to server thread.
// Handshake completed signal to server thread.
static
bool
client_handshake_complete
=
false
;
static
gpr_event
client_handshake_complete
;
static
int
create_socket
(
int
port
)
{
static
int
create_socket
(
int
port
)
{
int
s
;
int
s
;
...
@@ -111,7 +112,7 @@ static void server_thread(void *arg) {
...
@@ -111,7 +112,7 @@ static void server_thread(void *arg) {
// Wait a bounded number of time until client_handshake_complete is set,
// Wait a bounded number of time until client_handshake_complete is set,
// sleeping between polls.
// sleeping between polls.
int
retries
=
10
;
int
retries
=
10
;
while
(
!
client_handshake_complete
&&
retries
--
>
0
)
{
while
(
!
gpr_event_get
(
&
client_handshake_complete
)
&&
retries
--
>
0
)
{
const
gpr_timespec
cq_deadline
=
GRPC_TIMEOUT_SECONDS_TO_DEADLINE
(
1
);
const
gpr_timespec
cq_deadline
=
GRPC_TIMEOUT_SECONDS_TO_DEADLINE
(
1
);
grpc_event
ev
=
grpc_completion_queue_next
(
cq
,
cq_deadline
,
NULL
);
grpc_event
ev
=
grpc_completion_queue_next
(
cq
,
cq_deadline
,
NULL
);
GPR_ASSERT
(
ev
.
type
==
GRPC_QUEUE_TIMEOUT
);
GPR_ASSERT
(
ev
.
type
==
GRPC_QUEUE_TIMEOUT
);
...
@@ -143,7 +144,7 @@ static bool server_ssl_test(const char *alpn_list[], unsigned int alpn_list_len,
...
@@ -143,7 +144,7 @@ static bool server_ssl_test(const char *alpn_list[], unsigned int alpn_list_len,
grpc_init
();
grpc_init
();
int
port
=
grpc_pick_unused_port_or_die
();
int
port
=
grpc_pick_unused_port_or_die
();
client_handshake_complete
=
false
;
gpr_event_init
(
&
client_handshake_complete
)
;
// Launch the gRPC server thread.
// Launch the gRPC server thread.
gpr_thd_options
thdopt
=
gpr_thd_options_default
();
gpr_thd_options
thdopt
=
gpr_thd_options_default
();
...
@@ -233,7 +234,7 @@ static bool server_ssl_test(const char *alpn_list[], unsigned int alpn_list_len,
...
@@ -233,7 +234,7 @@ static bool server_ssl_test(const char *alpn_list[], unsigned int alpn_list_len,
success
=
false
;
success
=
false
;
}
}
}
}
client_handshake_complete
=
true
;
gpr_event_set
(
&
client_handshake_complete
,
&
client_handshake_complete
)
;
SSL_free
(
ssl
);
SSL_free
(
ssl
);
gpr_free
(
alpn_protos
);
gpr_free
(
alpn_protos
);
...
...
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