Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
L
lxc
Project
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Chen Yisong
lxc
Commits
27630009
Unverified
Commit
27630009
authored
Feb 18, 2021
by
Christian Brauner
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
cgroups: use close_equal() and free_equal()
Signed-off-by:
Christian Brauner
<
christian.brauner@ubuntu.com
>
parent
de6dc23c
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
9 additions
and
35 deletions
+9
-35
cgfsng.c
src/lxc/cgroups/cgfsng.c
+3
-9
cgroup.c
src/lxc/cgroups/cgroup.c
+6
-26
No files found.
src/lxc/cgroups/cgfsng.c
View file @
27630009
...
@@ -797,9 +797,7 @@ static int cgroup_tree_remove(struct hierarchy **hierarchies, const char *path_p
...
@@ -797,9 +797,7 @@ static int cgroup_tree_remove(struct hierarchy **hierarchies, const char *path_p
else
else
TRACE
(
"Removed cgroup tree %d(%s)"
,
h
->
dfd_base
,
path_prune
);
TRACE
(
"Removed cgroup tree %d(%s)"
,
h
->
dfd_base
,
path_prune
);
if
(
h
->
container_limit_path
!=
h
->
container_full_path
)
free_equal
(
h
->
container_limit_path
,
h
->
container_full_path
);
free_disarm
(
h
->
container_limit_path
);
free_disarm
(
h
->
container_full_path
);
}
}
return
0
;
return
0
;
...
@@ -1185,12 +1183,8 @@ static void cgroup_tree_prune_leaf(struct hierarchy *h, const char *path_prune,
...
@@ -1185,12 +1183,8 @@ static void cgroup_tree_prune_leaf(struct hierarchy *h, const char *path_prune,
if
(
h
->
cgfd_limit
<
0
)
if
(
h
->
cgfd_limit
<
0
)
prune
=
false
;
prune
=
false
;
if
(
h
->
container_full_path
!=
h
->
container_limit_path
)
free_equal
(
h
->
container_full_path
,
h
->
container_limit_path
);
free_disarm
(
h
->
container_limit_path
);
close_equal
(
h
->
cgfd_con
,
h
->
cgfd_limit
);
free_disarm
(
h
->
container_full_path
);
close_prot_errno_disarm
(
h
->
cgfd_con
);
close_prot_errno_disarm
(
h
->
cgfd_limit
);
}
else
{
}
else
{
/* Check whether we actually created the cgroup to prune. */
/* Check whether we actually created the cgroup to prune. */
if
(
h
->
cgfd_mon
<
0
)
if
(
h
->
cgfd_mon
<
0
)
...
...
src/lxc/cgroups/cgroup.c
View file @
27630009
...
@@ -14,6 +14,7 @@
...
@@ -14,6 +14,7 @@
#include "conf.h"
#include "conf.h"
#include "config.h"
#include "config.h"
#include "initutils.h"
#include "initutils.h"
#include "memory_utils.h"
#include "log.h"
#include "log.h"
#include "start.h"
#include "start.h"
#include "string_utils.h"
#include "string_utils.h"
...
@@ -68,11 +69,7 @@ void cgroup_exit(struct cgroup_ops *ops)
...
@@ -68,11 +69,7 @@ void cgroup_exit(struct cgroup_ops *ops)
free
(
ops
->
cgroup_pattern
);
free
(
ops
->
cgroup_pattern
);
free
(
ops
->
monitor_cgroup
);
free
(
ops
->
monitor_cgroup
);
{
free_equal
(
ops
->
container_cgroup
,
ops
->
container_limit_cgroup
);
if
(
ops
->
container_cgroup
!=
ops
->
container_limit_cgroup
)
free
(
ops
->
container_limit_cgroup
);
free
(
ops
->
container_cgroup
);
}
if
(
ops
->
cgroup2_devices
)
if
(
ops
->
cgroup2_devices
)
bpf_program_free
(
ops
->
cgroup2_devices
);
bpf_program_free
(
ops
->
cgroup2_devices
);
...
@@ -92,32 +89,15 @@ void cgroup_exit(struct cgroup_ops *ops)
...
@@ -92,32 +89,15 @@ void cgroup_exit(struct cgroup_ops *ops)
free
((
*
it
)
->
mountpoint
);
free
((
*
it
)
->
mountpoint
);
free
((
*
it
)
->
container_base_path
);
free
((
*
it
)
->
container_base_path
);
{
free_equal
((
*
it
)
->
container_full_path
,
free
((
*
it
)
->
container_full_path
);
(
*
it
)
->
container_limit_path
);
if
((
*
it
)
->
container_full_path
!=
(
*
it
)
->
container_limit_path
)
free
((
*
it
)
->
container_limit_path
);
}
{
if
((
*
it
)
->
cgfd_limit
>=
0
&&
(
*
it
)
->
cgfd_con
!=
(
*
it
)
->
cgfd_limit
)
close
((
*
it
)
->
cgfd_limit
);
if
((
*
it
)
->
cgfd_con
>=
0
)
close_equal
((
*
it
)
->
cgfd_con
,
(
*
it
)
->
cgfd_limit
);
close
((
*
it
)
->
cgfd_con
);
}
if
((
*
it
)
->
cgfd_mon
>=
0
)
if
((
*
it
)
->
cgfd_mon
>=
0
)
close
((
*
it
)
->
cgfd_mon
);
close
((
*
it
)
->
cgfd_mon
);
{
close_equal
((
*
it
)
->
dfd_base
,
(
*
it
)
->
dfd_mnt
);
if
((
*
it
)
->
dfd_base
>=
0
&&
(
*
it
)
->
dfd_mnt
!=
(
*
it
)
->
dfd_base
)
close
((
*
it
)
->
dfd_base
);
if
((
*
it
)
->
dfd_mnt
>=
0
)
close
((
*
it
)
->
dfd_mnt
);
}
free
(
*
it
);
free
(
*
it
);
}
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment