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
c0c0dbc0
Commit
c0c0dbc0
authored
8 years ago
by
Craig Tiller
Browse files
Options
Downloads
Patches
Plain Diff
Fix TSAN race on adding a reclaimer
parent
54c607dc
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/core/lib/iomgr/resource_quota.c
+24
-6
24 additions, 6 deletions
src/core/lib/iomgr/resource_quota.c
with
24 additions
and
6 deletions
src/core/lib/iomgr/resource_quota.c
+
24
−
6
View file @
c0c0dbc0
...
...
@@ -104,6 +104,9 @@ struct grpc_resource_user {
/* Reclaimers: index 0 is the benign reclaimer, 1 is the destructive reclaimer
*/
grpc_closure
*
reclaimers
[
2
];
/* Reclaimers just posted: once we're in the combiner lock, we'll move them
to the array above */
grpc_closure
*
new_reclaimers
[
2
];
/* Trampoline closures to finish reclamation and re-enter the quota combiner
lock */
grpc_closure
post_reclaimer_closure
[
2
];
...
...
@@ -418,9 +421,25 @@ static void ru_add_to_free_pool(grpc_exec_ctx *exec_ctx, void *ru,
rulist_add_tail
(
resource_user
,
GRPC_RULIST_NON_EMPTY_FREE_POOL
);
}
static
bool
ru_post_reclaimer
(
grpc_exec_ctx
*
exec_ctx
,
grpc_resource_user
*
resource_user
,
bool
destructive
)
{
grpc_closure
*
closure
=
resource_user
->
new_reclaimers
[
destructive
];
GPR_ASSERT
(
closure
!=
NULL
);
resource_user
->
new_reclaimers
[
destructive
]
=
NULL
;
GPR_ASSERT
(
resource_user
->
reclaimers
[
destructive
]
==
NULL
);
if
(
gpr_atm_acq_load
(
&
resource_user
->
shutdown
)
>
0
)
{
grpc_exec_ctx_sched
(
exec_ctx
,
closure
,
GRPC_ERROR_CANCELLED
,
NULL
);
return
false
;
}
resource_user
->
reclaimers
[
destructive
]
=
closure
;
return
true
;
}
static
void
ru_post_benign_reclaimer
(
grpc_exec_ctx
*
exec_ctx
,
void
*
ru
,
grpc_error
*
error
)
{
grpc_resource_user
*
resource_user
=
ru
;
if
(
!
ru_post_reclaimer
(
exec_ctx
,
resource_user
,
false
))
return
;
if
(
!
rulist_empty
(
resource_user
->
resource_quota
,
GRPC_RULIST_AWAITING_ALLOCATION
)
&&
rulist_empty
(
resource_user
->
resource_quota
,
...
...
@@ -435,6 +454,7 @@ static void ru_post_benign_reclaimer(grpc_exec_ctx *exec_ctx, void *ru,
static
void
ru_post_destructive_reclaimer
(
grpc_exec_ctx
*
exec_ctx
,
void
*
ru
,
grpc_error
*
error
)
{
grpc_resource_user
*
resource_user
=
ru
;
if
(
!
ru_post_reclaimer
(
exec_ctx
,
resource_user
,
true
))
return
;
if
(
!
rulist_empty
(
resource_user
->
resource_quota
,
GRPC_RULIST_AWAITING_ALLOCATION
)
&&
rulist_empty
(
resource_user
->
resource_quota
,
...
...
@@ -649,6 +669,8 @@ grpc_resource_user *grpc_resource_user_create(
resource_user
->
added_to_free_pool
=
false
;
resource_user
->
reclaimers
[
0
]
=
NULL
;
resource_user
->
reclaimers
[
1
]
=
NULL
;
resource_user
->
new_reclaimers
[
0
]
=
NULL
;
resource_user
->
new_reclaimers
[
1
]
=
NULL
;
for
(
int
i
=
0
;
i
<
GRPC_RULIST_COUNT
;
i
++
)
{
resource_user
->
links
[
i
].
next
=
resource_user
->
links
[
i
].
prev
=
NULL
;
}
...
...
@@ -748,12 +770,8 @@ void grpc_resource_user_post_reclaimer(grpc_exec_ctx *exec_ctx,
grpc_resource_user
*
resource_user
,
bool
destructive
,
grpc_closure
*
closure
)
{
GPR_ASSERT
(
resource_user
->
reclaimers
[
destructive
]
==
NULL
);
if
(
gpr_atm_acq_load
(
&
resource_user
->
shutdown
)
>
0
)
{
grpc_exec_ctx_sched
(
exec_ctx
,
closure
,
GRPC_ERROR_CANCELLED
,
NULL
);
return
;
}
resource_user
->
reclaimers
[
destructive
]
=
closure
;
GPR_ASSERT
(
resource_user
->
new_reclaimers
[
destructive
]
==
NULL
);
resource_user
->
new_reclaimers
[
destructive
]
=
closure
;
grpc_combiner_execute
(
exec_ctx
,
resource_user
->
resource_quota
->
combiner
,
&
resource_user
->
post_reclaimer_closure
[
destructive
],
GRPC_ERROR_NONE
,
false
);
...
...
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