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
6b6c6b2b
Commit
6b6c6b2b
authored
Mar 09, 2016
by
Christian Brauner
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #884 from hallyn/2016-03-08/batch
2016 03 08/batch
parents
5d5c5694
d8da679e
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
19 additions
and
5 deletions
+19
-5
cgfsng.c
src/lxc/cgfsng.c
+19
-5
No files found.
src/lxc/cgfsng.c
View file @
6b6c6b2b
...
@@ -621,13 +621,24 @@ static char *get_current_cgroup(char *basecginfo, char *controller)
...
@@ -621,13 +621,24 @@ static char *get_current_cgroup(char *basecginfo, char *controller)
}
}
}
}
#define BATCH_SIZE 50
static
void
batch_realloc
(
char
**
mem
,
size_t
oldlen
,
size_t
newlen
)
{
int
newbatches
=
(
newlen
/
BATCH_SIZE
)
+
1
;
int
oldbatches
=
(
oldlen
/
BATCH_SIZE
)
+
1
;
if
(
!*
mem
||
newbatches
>
oldbatches
)
{
*
mem
=
must_realloc
(
*
mem
,
newbatches
*
BATCH_SIZE
);
}
}
static
void
append_line
(
char
**
dest
,
size_t
oldlen
,
char
*
new
,
size_t
newlen
)
static
void
append_line
(
char
**
dest
,
size_t
oldlen
,
char
*
new
,
size_t
newlen
)
{
{
size_t
full
=
oldlen
+
newlen
;
size_t
full
=
oldlen
+
newlen
;
*
dest
=
must_realloc
(
*
dest
,
full
+
1
);
batch_realloc
(
dest
,
oldlen
,
full
+
1
);
strcat
(
*
dest
,
new
);
memcpy
(
*
dest
+
oldlen
,
new
,
newlen
+
1
);
}
}
/* Slurp in a whole file */
/* Slurp in a whole file */
...
@@ -636,13 +647,14 @@ static char *read_file(char *fnam)
...
@@ -636,13 +647,14 @@ static char *read_file(char *fnam)
FILE
*
f
;
FILE
*
f
;
char
*
line
=
NULL
,
*
buf
=
NULL
;
char
*
line
=
NULL
,
*
buf
=
NULL
;
size_t
len
=
0
,
fulllen
=
0
;
size_t
len
=
0
,
fulllen
=
0
;
int
linelen
;
f
=
fopen
(
fnam
,
"r"
);
f
=
fopen
(
fnam
,
"r"
);
if
(
!
f
)
if
(
!
f
)
return
NULL
;
return
NULL
;
while
(
getline
(
&
line
,
&
len
,
f
)
!=
-
1
)
{
while
(
(
linelen
=
getline
(
&
line
,
&
len
,
f
)
)
!=
-
1
)
{
append_line
(
&
buf
,
fulllen
,
line
,
len
);
append_line
(
&
buf
,
fulllen
,
line
,
l
inel
en
);
fulllen
+=
len
;
fulllen
+=
l
inel
en
;
}
}
fclose
(
f
);
fclose
(
f
);
free
(
line
);
free
(
line
);
...
@@ -1019,6 +1031,8 @@ struct cgroup_ops *cgfsng_ops_init(void)
...
@@ -1019,6 +1031,8 @@ struct cgroup_ops *cgfsng_ops_init(void)
static
bool
create_path_for_hierarchy
(
struct
hierarchy
*
h
,
char
*
cgname
)
static
bool
create_path_for_hierarchy
(
struct
hierarchy
*
h
,
char
*
cgname
)
{
{
h
->
fullcgpath
=
must_make_path
(
h
->
mountpoint
,
h
->
base_cgroup
,
cgname
,
NULL
);
h
->
fullcgpath
=
must_make_path
(
h
->
mountpoint
,
h
->
base_cgroup
,
cgname
,
NULL
);
if
(
dir_exists
(
h
->
fullcgpath
))
// it must not already exist
return
false
;
if
(
!
handle_cpuset_hierarchy
(
h
,
cgname
))
if
(
!
handle_cpuset_hierarchy
(
h
,
cgname
))
return
false
;
return
false
;
return
mkdir_p
(
h
->
fullcgpath
,
0755
)
==
0
;
return
mkdir_p
(
h
->
fullcgpath
,
0755
)
==
0
;
...
...
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