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
6cb61569
Commit
6cb61569
authored
7 years ago
by
Craig Tiller
Browse files
Options
Downloads
Patches
Plain Diff
Fix race
parent
cfa8313f
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/iomgr/resource_quota_test.c
+22
-3
22 additions, 3 deletions
test/core/iomgr/resource_quota_test.c
with
22 additions
and
3 deletions
test/core/iomgr/resource_quota_test.c
+
22
−
3
View file @
6cb61569
...
@@ -39,8 +39,23 @@
...
@@ -39,8 +39,23 @@
#include
"src/core/lib/slice/slice_internal.h"
#include
"src/core/lib/slice/slice_internal.h"
#include
"test/core/util/test_config.h"
#include
"test/core/util/test_config.h"
gpr_mu
g_mu
;
gpr_cv
g_cv
;
static
void
inc_int_cb
(
grpc_exec_ctx
*
exec_ctx
,
void
*
a
,
grpc_error
*
error
)
{
static
void
inc_int_cb
(
grpc_exec_ctx
*
exec_ctx
,
void
*
a
,
grpc_error
*
error
)
{
gpr_mu_lock
(
&
g_mu
);
++*
(
int
*
)
a
;
++*
(
int
*
)
a
;
gpr_cv_signal
(
&
g_cv
);
gpr_mu_unlock
(
&
g_mu
);
}
static
void
assert_counter_becomes
(
int
*
ctr
,
int
value
)
{
gpr_mu_lock
(
&
g_mu
);
gpr_timespec
deadline
=
grpc_timeout_seconds_to_deadline
(
5
);
while
(
*
ctr
!=
value
)
{
GPR_ASSERT
(
!
gpr_cv_wait
(
&
g_cv
,
&
g_mu
,
deadline
));
}
gpr_mu_unlock
(
&
g_mu
);
}
}
static
void
set_event_cb
(
grpc_exec_ctx
*
exec_ctx
,
void
*
a
,
grpc_error
*
error
)
{
static
void
set_event_cb
(
grpc_exec_ctx
*
exec_ctx
,
void
*
a
,
grpc_error
*
error
)
{
...
@@ -730,7 +745,7 @@ static void test_one_slice(void) {
...
@@ -730,7 +745,7 @@ static void test_one_slice(void) {
grpc_exec_ctx
exec_ctx
=
GRPC_EXEC_CTX_INIT
;
grpc_exec_ctx
exec_ctx
=
GRPC_EXEC_CTX_INIT
;
grpc_resource_user_alloc_slices
(
&
exec_ctx
,
&
alloc
,
1024
,
1
,
&
buffer
);
grpc_resource_user_alloc_slices
(
&
exec_ctx
,
&
alloc
,
1024
,
1
,
&
buffer
);
grpc_exec_ctx_finish
(
&
exec_ctx
);
grpc_exec_ctx_finish
(
&
exec_ctx
);
GPR_ASSERT
(
num_allocs
==
start_allocs
+
1
);
assert_counter_becomes
(
&
num_allocs
,
start_allocs
+
1
);
}
}
{
{
...
@@ -763,7 +778,7 @@ static void test_one_slice_deleted_late(void) {
...
@@ -763,7 +778,7 @@ static void test_one_slice_deleted_late(void) {
grpc_exec_ctx
exec_ctx
=
GRPC_EXEC_CTX_INIT
;
grpc_exec_ctx
exec_ctx
=
GRPC_EXEC_CTX_INIT
;
grpc_resource_user_alloc_slices
(
&
exec_ctx
,
&
alloc
,
1024
,
1
,
&
buffer
);
grpc_resource_user_alloc_slices
(
&
exec_ctx
,
&
alloc
,
1024
,
1
,
&
buffer
);
grpc_exec_ctx_finish
(
&
exec_ctx
);
grpc_exec_ctx_finish
(
&
exec_ctx
);
GPR_ASSERT
(
num_allocs
==
start_allocs
+
1
);
assert_counter_becomes
(
&
num_allocs
,
start_allocs
+
1
);
}
}
{
{
...
@@ -807,7 +822,7 @@ static void test_negative_rq_free_pool(void) {
...
@@ -807,7 +822,7 @@ static void test_negative_rq_free_pool(void) {
grpc_exec_ctx
exec_ctx
=
GRPC_EXEC_CTX_INIT
;
grpc_exec_ctx
exec_ctx
=
GRPC_EXEC_CTX_INIT
;
grpc_resource_user_alloc_slices
(
&
exec_ctx
,
&
alloc
,
1024
,
1
,
&
buffer
);
grpc_resource_user_alloc_slices
(
&
exec_ctx
,
&
alloc
,
1024
,
1
,
&
buffer
);
grpc_exec_ctx_finish
(
&
exec_ctx
);
grpc_exec_ctx_finish
(
&
exec_ctx
);
GPR_ASSERT
(
num_allocs
==
start_allocs
+
1
);
assert_counter_becomes
(
&
num_allocs
,
start_allocs
+
1
);
}
}
grpc_resource_quota_resize
(
q
,
512
);
grpc_resource_quota_resize
(
q
,
512
);
...
@@ -833,6 +848,8 @@ static void test_negative_rq_free_pool(void) {
...
@@ -833,6 +848,8 @@ static void test_negative_rq_free_pool(void) {
int
main
(
int
argc
,
char
**
argv
)
{
int
main
(
int
argc
,
char
**
argv
)
{
grpc_test_init
(
argc
,
argv
);
grpc_test_init
(
argc
,
argv
);
grpc_init
();
grpc_init
();
gpr_mu_init
(
&
g_mu
);
gpr_cv_init
(
&
g_cv
);
test_no_op
();
test_no_op
();
test_resize_then_destroy
();
test_resize_then_destroy
();
test_resource_user_no_op
();
test_resource_user_no_op
();
...
@@ -855,6 +872,8 @@ int main(int argc, char **argv) {
...
@@ -855,6 +872,8 @@ int main(int argc, char **argv) {
test_one_slice_deleted_late
();
test_one_slice_deleted_late
();
test_resize_to_zero
();
test_resize_to_zero
();
test_negative_rq_free_pool
();
test_negative_rq_free_pool
();
gpr_mu_destroy
(
&
g_mu
);
gpr_cv_destroy
(
&
g_cv
);
grpc_shutdown
();
grpc_shutdown
();
return
0
;
return
0
;
}
}
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