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
6cf61536
Commit
6cf61536
authored
8 years ago
by
Mark D. Roth
Browse files
Options
Downloads
Patches
Plain Diff
Fix tsan failures.
parent
ad1b3952
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/end2end/tests/filter_latency.c
+13
-1
13 additions, 1 deletion
test/core/end2end/tests/filter_latency.c
with
13 additions
and
1 deletion
test/core/end2end/tests/filter_latency.c
+
13
−
1
View file @
6cf61536
...
@@ -51,6 +51,7 @@
...
@@ -51,6 +51,7 @@
enum
{
TIMEOUT
=
200000
};
enum
{
TIMEOUT
=
200000
};
static
bool
g_enable_filter
=
false
;
static
bool
g_enable_filter
=
false
;
static
gpr_mu
g_mu
;
static
gpr_timespec
g_client_latency
;
static
gpr_timespec
g_client_latency
;
static
gpr_timespec
g_server_latency
;
static
gpr_timespec
g_server_latency
;
...
@@ -131,8 +132,10 @@ static void test_request(grpc_end2end_test_config config) {
...
@@ -131,8 +132,10 @@ static void test_request(grpc_end2end_test_config config) {
size_t
details_capacity
=
0
;
size_t
details_capacity
=
0
;
int
was_cancelled
=
2
;
int
was_cancelled
=
2
;
gpr_mu_lock
(
&
g_mu
);
g_client_latency
=
gpr_time_0
(
GPR_TIMESPAN
);
g_client_latency
=
gpr_time_0
(
GPR_TIMESPAN
);
g_server_latency
=
gpr_time_0
(
GPR_TIMESPAN
);
g_server_latency
=
gpr_time_0
(
GPR_TIMESPAN
);
gpr_mu_unlock
(
&
g_mu
);
const
gpr_timespec
start_time
=
gpr_now
(
GPR_CLOCK_MONOTONIC
);
const
gpr_timespec
start_time
=
gpr_now
(
GPR_CLOCK_MONOTONIC
);
c
=
grpc_channel_create_call
(
f
.
client
,
NULL
,
GRPC_PROPAGATE_DEFAULTS
,
f
.
cq
,
c
=
grpc_channel_create_call
(
f
.
client
,
NULL
,
GRPC_PROPAGATE_DEFAULTS
,
f
.
cq
,
...
@@ -226,12 +229,14 @@ static void test_request(grpc_end2end_test_config config) {
...
@@ -226,12 +229,14 @@ static void test_request(grpc_end2end_test_config config) {
const
gpr_timespec
end_time
=
gpr_now
(
GPR_CLOCK_MONOTONIC
);
const
gpr_timespec
end_time
=
gpr_now
(
GPR_CLOCK_MONOTONIC
);
const
gpr_timespec
max_latency
=
gpr_time_sub
(
end_time
,
start_time
);
const
gpr_timespec
max_latency
=
gpr_time_sub
(
end_time
,
start_time
);
gpr_mu_lock
(
&
g_mu
);
GPR_ASSERT
(
gpr_time_cmp
(
max_latency
,
g_client_latency
)
>=
0
);
GPR_ASSERT
(
gpr_time_cmp
(
max_latency
,
g_client_latency
)
>=
0
);
GPR_ASSERT
(
gpr_time_cmp
(
gpr_time_0
(
GPR_TIMESPAN
),
g_client_latency
)
<
0
);
GPR_ASSERT
(
gpr_time_cmp
(
gpr_time_0
(
GPR_TIMESPAN
),
g_client_latency
)
<
0
);
GPR_ASSERT
(
gpr_time_cmp
(
max_latency
,
g_server_latency
)
>=
0
);
GPR_ASSERT
(
gpr_time_cmp
(
max_latency
,
g_server_latency
)
>=
0
);
GPR_ASSERT
(
gpr_time_cmp
(
gpr_time_0
(
GPR_TIMESPAN
),
g_server_latency
)
<
0
);
GPR_ASSERT
(
gpr_time_cmp
(
gpr_time_0
(
GPR_TIMESPAN
),
g_server_latency
)
<
0
);
// Server latency should always be smaller than client latency.
// Server latency should always be smaller than client latency.
GPR_ASSERT
(
gpr_time_cmp
(
g_server_latency
,
g_client_latency
)
<
0
);
GPR_ASSERT
(
gpr_time_cmp
(
g_server_latency
,
g_client_latency
)
<
0
);
gpr_mu_unlock
(
&
g_mu
);
cq_verifier_destroy
(
cqv
);
cq_verifier_destroy
(
cqv
);
...
@@ -256,14 +261,18 @@ static void client_destroy_call_elem(grpc_exec_ctx *exec_ctx,
...
@@ -256,14 +261,18 @@ static void client_destroy_call_elem(grpc_exec_ctx *exec_ctx,
grpc_call_element
*
elem
,
grpc_call_element
*
elem
,
const
grpc_call_final_info
*
final_info
,
const
grpc_call_final_info
*
final_info
,
void
*
and_free_memory
)
{
void
*
and_free_memory
)
{
gpr_mu_lock
(
&
g_mu
);
g_client_latency
=
final_info
->
stats
.
latency
;
g_client_latency
=
final_info
->
stats
.
latency
;
gpr_mu_unlock
(
&
g_mu
);
}
}
static
void
server_destroy_call_elem
(
grpc_exec_ctx
*
exec_ctx
,
static
void
server_destroy_call_elem
(
grpc_exec_ctx
*
exec_ctx
,
grpc_call_element
*
elem
,
grpc_call_element
*
elem
,
const
grpc_call_final_info
*
final_info
,
const
grpc_call_final_info
*
final_info
,
void
*
and_free_memory
)
{
void
*
and_free_memory
)
{
gpr_mu_lock
(
&
g_mu
);
g_server_latency
=
final_info
->
stats
.
latency
;
g_server_latency
=
final_info
->
stats
.
latency
;
gpr_mu_unlock
(
&
g_mu
);
}
}
static
void
init_channel_elem
(
grpc_exec_ctx
*
exec_ctx
,
static
void
init_channel_elem
(
grpc_exec_ctx
*
exec_ctx
,
...
@@ -325,6 +334,7 @@ static bool maybe_add_filter(grpc_channel_stack_builder *builder, void *arg) {
...
@@ -325,6 +334,7 @@ static bool maybe_add_filter(grpc_channel_stack_builder *builder, void *arg) {
}
}
static
void
init_plugin
(
void
)
{
static
void
init_plugin
(
void
)
{
gpr_mu_init
(
&
g_mu
);
grpc_channel_init_register_stage
(
GRPC_CLIENT_CHANNEL
,
INT_MAX
,
grpc_channel_init_register_stage
(
GRPC_CLIENT_CHANNEL
,
INT_MAX
,
maybe_add_filter
,
maybe_add_filter
,
(
void
*
)
&
test_client_filter
);
(
void
*
)
&
test_client_filter
);
...
@@ -336,7 +346,9 @@ static void init_plugin(void) {
...
@@ -336,7 +346,9 @@ static void init_plugin(void) {
(
void
*
)
&
test_server_filter
);
(
void
*
)
&
test_server_filter
);
}
}
static
void
destroy_plugin
(
void
)
{}
static
void
destroy_plugin
(
void
)
{
gpr_mu_destroy
(
&
g_mu
);
}
void
filter_latency
(
grpc_end2end_test_config
config
)
{
void
filter_latency
(
grpc_end2end_test_config
config
)
{
g_enable_filter
=
true
;
g_enable_filter
=
true
;
...
...
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