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
12b925d2
Commit
12b925d2
authored
8 years ago
by
Craig Tiller
Browse files
Options
Downloads
Patches
Plain Diff
Made scavenging work
parent
b7810a14
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/iomgr/buffer_pool.c
+2
-2
2 additions, 2 deletions
src/core/lib/iomgr/buffer_pool.c
test/core/iomgr/buffer_pool_test.c
+38
-0
38 additions, 0 deletions
test/core/iomgr/buffer_pool_test.c
with
40 additions
and
2 deletions
src/core/lib/iomgr/buffer_pool.c
+
2
−
2
View file @
12b925d2
...
...
@@ -193,7 +193,7 @@ static bool bpscavenge(grpc_exec_ctx *exec_ctx, grpc_buffer_pool *buffer_pool) {
while
((
buffer_user
=
bulist_pop
(
buffer_pool
,
GRPC_BULIST_NON_EMPTY_FREE_POOL
)))
{
gpr_mu_lock
(
&
buffer_user
->
mu
);
if
(
buffer_
pool
->
free_pool
>
0
)
{
if
(
buffer_
user
->
free_pool
>
0
)
{
buffer_pool
->
free_pool
+=
buffer_user
->
free_pool
;
buffer_user
->
free_pool
=
0
;
gpr_mu_unlock
(
&
buffer_user
->
mu
);
...
...
@@ -240,7 +240,7 @@ static void bu_add_to_free_pool(grpc_exec_ctx *exec_ctx, void *bu,
bulist_empty
(
buffer_user
->
buffer_pool
,
GRPC_BULIST_NON_EMPTY_FREE_POOL
))
{
bpstep_sched
(
exec_ctx
,
buffer_user
->
buffer_pool
);
}
bulist_add_tail
(
buffer_user
,
GRPC_BULIST_
AWAITING_ALLOCATION
);
bulist_add_tail
(
buffer_user
,
GRPC_BULIST_
NON_EMPTY_FREE_POOL
);
}
static
void
bu_post_benign_reclaimer
(
grpc_exec_ctx
*
exec_ctx
,
void
*
bu
,
...
...
This diff is collapsed.
Click to expand it.
test/core/iomgr/buffer_pool_test.c
+
38
−
0
View file @
12b925d2
...
...
@@ -153,6 +153,43 @@ static void test_async_alloc_blocked_by_size(void) {
destroy_user
(
&
usr
);
}
static
void
test_scavenge
(
void
)
{
gpr_log
(
GPR_INFO
,
"** test_scavenge **"
);
grpc_buffer_pool
*
p
=
grpc_buffer_pool_create
();
grpc_buffer_pool_resize
(
p
,
1024
);
grpc_buffer_user
usr1
;
grpc_buffer_user
usr2
;
grpc_buffer_user_init
(
&
usr1
,
p
);
grpc_buffer_user_init
(
&
usr2
,
p
);
{
bool
done
=
false
;
grpc_exec_ctx
exec_ctx
=
GRPC_EXEC_CTX_INIT
;
grpc_buffer_user_alloc
(
&
exec_ctx
,
&
usr1
,
1024
,
set_bool
(
&
done
));
grpc_exec_ctx_finish
(
&
exec_ctx
);
GPR_ASSERT
(
done
);
}
{
grpc_exec_ctx
exec_ctx
=
GRPC_EXEC_CTX_INIT
;
grpc_buffer_user_free
(
&
exec_ctx
,
&
usr1
,
1024
);
grpc_exec_ctx_finish
(
&
exec_ctx
);
}
{
bool
done
=
false
;
grpc_exec_ctx
exec_ctx
=
GRPC_EXEC_CTX_INIT
;
grpc_buffer_user_alloc
(
&
exec_ctx
,
&
usr2
,
1024
,
set_bool
(
&
done
));
grpc_exec_ctx_finish
(
&
exec_ctx
);
GPR_ASSERT
(
done
);
}
{
grpc_exec_ctx
exec_ctx
=
GRPC_EXEC_CTX_INIT
;
grpc_buffer_user_free
(
&
exec_ctx
,
&
usr2
,
1024
);
grpc_exec_ctx_finish
(
&
exec_ctx
);
}
grpc_buffer_pool_unref
(
p
);
destroy_user
(
&
usr1
);
destroy_user
(
&
usr2
);
}
int
main
(
int
argc
,
char
**
argv
)
{
grpc_test_init
(
argc
,
argv
);
grpc_init
();
...
...
@@ -163,6 +200,7 @@ int main(int argc, char **argv) {
test_instant_alloc_free_pair
();
test_simple_async_alloc
();
test_async_alloc_blocked_by_size
();
test_scavenge
();
grpc_shutdown
();
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