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
081f3eb4
Unverified
Commit
081f3eb4
authored
Jun 11, 2017
by
Christian Brauner
Committed by
Stéphane Graber
Jul 16, 2017
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
{start,lxccontainer}: add lxc_free_handler()
Signed-off-by:
Christian Brauner
<
christian.brauner@ubuntu.com
>
parent
3988d163
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
26 additions
and
8 deletions
+26
-8
lxccontainer.c
src/lxc/lxccontainer.c
+9
-1
start.c
src/lxc/start.c
+16
-7
start.h
src/lxc/start.h
+1
-0
No files found.
src/lxc/lxccontainer.c
View file @
081f3eb4
...
@@ -792,8 +792,10 @@ static bool do_lxcapi_start(struct lxc_container *c, int useinit, char * const a
...
@@ -792,8 +792,10 @@ static bool do_lxcapi_start(struct lxc_container *c, int useinit, char * const a
char
title
[
2048
];
char
title
[
2048
];
pid_t
pid
=
fork
();
pid_t
pid
=
fork
();
if
(
pid
<
0
)
if
(
pid
<
0
)
{
lxc_free_handler
(
handler
);
return
false
;
return
false
;
}
if
(
pid
!=
0
)
{
if
(
pid
!=
0
)
{
/* Set to NULL because we don't want father unlink
/* Set to NULL because we don't want father unlink
...
@@ -834,6 +836,7 @@ static bool do_lxcapi_start(struct lxc_container *c, int useinit, char * const a
...
@@ -834,6 +836,7 @@ static bool do_lxcapi_start(struct lxc_container *c, int useinit, char * const a
}
else
{
}
else
{
if
(
!
am_single_threaded
())
{
if
(
!
am_single_threaded
())
{
ERROR
(
"Cannot start non-daemonized container when threaded"
);
ERROR
(
"Cannot start non-daemonized container when threaded"
);
lxc_free_handler
(
handler
);
return
false
;
return
false
;
}
}
}
}
...
@@ -846,6 +849,7 @@ static bool do_lxcapi_start(struct lxc_container *c, int useinit, char * const a
...
@@ -846,6 +849,7 @@ static bool do_lxcapi_start(struct lxc_container *c, int useinit, char * const a
if
(
pid_fp
==
NULL
)
{
if
(
pid_fp
==
NULL
)
{
SYSERROR
(
"Failed to create pidfile '%s' for '%s'"
,
SYSERROR
(
"Failed to create pidfile '%s' for '%s'"
,
c
->
pidfile
,
c
->
name
);
c
->
pidfile
,
c
->
name
);
lxc_free_handler
(
handler
);
if
(
daemonize
)
if
(
daemonize
)
exit
(
1
);
exit
(
1
);
return
false
;
return
false
;
...
@@ -855,6 +859,7 @@ static bool do_lxcapi_start(struct lxc_container *c, int useinit, char * const a
...
@@ -855,6 +859,7 @@ static bool do_lxcapi_start(struct lxc_container *c, int useinit, char * const a
SYSERROR
(
"Failed to write '%s'"
,
c
->
pidfile
);
SYSERROR
(
"Failed to write '%s'"
,
c
->
pidfile
);
fclose
(
pid_fp
);
fclose
(
pid_fp
);
pid_fp
=
NULL
;
pid_fp
=
NULL
;
lxc_free_handler
(
handler
);
if
(
daemonize
)
if
(
daemonize
)
exit
(
1
);
exit
(
1
);
return
false
;
return
false
;
...
@@ -870,10 +875,12 @@ static bool do_lxcapi_start(struct lxc_container *c, int useinit, char * const a
...
@@ -870,10 +875,12 @@ static bool do_lxcapi_start(struct lxc_container *c, int useinit, char * const a
if
(
conf
->
monitor_unshare
)
{
if
(
conf
->
monitor_unshare
)
{
if
(
unshare
(
CLONE_NEWNS
))
{
if
(
unshare
(
CLONE_NEWNS
))
{
SYSERROR
(
"failed to unshare mount namespace"
);
SYSERROR
(
"failed to unshare mount namespace"
);
lxc_free_handler
(
handler
);
return
false
;
return
false
;
}
}
if
(
mount
(
NULL
,
"/"
,
NULL
,
MS_SLAVE
|
MS_REC
,
NULL
))
{
if
(
mount
(
NULL
,
"/"
,
NULL
,
MS_SLAVE
|
MS_REC
,
NULL
))
{
SYSERROR
(
"Failed to make / rslave at startup"
);
SYSERROR
(
"Failed to make / rslave at startup"
);
lxc_free_handler
(
handler
);
return
false
;
return
false
;
}
}
}
}
...
@@ -888,6 +895,7 @@ reboot:
...
@@ -888,6 +895,7 @@ reboot:
if
(
lxc_check_inherited
(
conf
,
daemonize
,
handler
->
conf
->
maincmd_fd
))
{
if
(
lxc_check_inherited
(
conf
,
daemonize
,
handler
->
conf
->
maincmd_fd
))
{
ERROR
(
"Inherited fds found"
);
ERROR
(
"Inherited fds found"
);
lxc_free_handler
(
handler
);
ret
=
1
;
ret
=
1
;
goto
out
;
goto
out
;
}
}
...
...
src/lxc/start.c
View file @
081f3eb4
...
@@ -437,6 +437,18 @@ out_sigfd:
...
@@ -437,6 +437,18 @@ out_sigfd:
return
-
1
;
return
-
1
;
}
}
void
lxc_free_handler
(
struct
lxc_handler
*
handler
)
{
if
(
handler
->
conf
&&
handler
->
conf
->
maincmd_fd
)
close
(
handler
->
conf
->
maincmd_fd
);
if
(
handler
->
name
)
free
(
handler
->
name
);
handler
->
conf
=
NULL
;
free
(
handler
);
}
struct
lxc_handler
*
lxc_init_handler
(
const
char
*
name
,
struct
lxc_conf
*
conf
,
struct
lxc_handler
*
lxc_init_handler
(
const
char
*
name
,
struct
lxc_conf
*
conf
,
const
char
*
lxcpath
)
const
char
*
lxcpath
)
{
{
...
@@ -463,12 +475,12 @@ struct lxc_handler *lxc_init_handler(const char *name, struct lxc_conf *conf,
...
@@ -463,12 +475,12 @@ struct lxc_handler *lxc_init_handler(const char *name, struct lxc_conf *conf,
handler
->
name
=
strdup
(
name
);
handler
->
name
=
strdup
(
name
);
if
(
!
handler
->
name
)
{
if
(
!
handler
->
name
)
{
ERROR
(
"failed to allocate memory"
);
ERROR
(
"failed to allocate memory"
);
goto
do_partial_cleanup
;
goto
on_error
;
}
}
if
(
lxc_cmd_init
(
name
,
handler
,
lxcpath
))
{
if
(
lxc_cmd_init
(
name
,
handler
,
lxcpath
))
{
ERROR
(
"failed to set up command socket"
);
ERROR
(
"failed to set up command socket"
);
goto
do_full_cleanup
;
goto
on_error
;
}
}
TRACE
(
"unix domain socket %d for command server is ready"
,
TRACE
(
"unix domain socket %d for command server is ready"
,
...
@@ -476,11 +488,8 @@ struct lxc_handler *lxc_init_handler(const char *name, struct lxc_conf *conf,
...
@@ -476,11 +488,8 @@ struct lxc_handler *lxc_init_handler(const char *name, struct lxc_conf *conf,
return
handler
;
return
handler
;
do_full_cleanup:
on_error:
free
(
handler
->
name
);
lxc_free_handler
(
handler
);
do_partial_cleanup:
free
(
handler
);
return
NULL
;
return
NULL
;
}
}
...
...
src/lxc/start.h
View file @
081f3eb4
...
@@ -69,6 +69,7 @@ extern void lxc_abort(const char *name, struct lxc_handler *handler);
...
@@ -69,6 +69,7 @@ extern void lxc_abort(const char *name, struct lxc_handler *handler);
extern
struct
lxc_handler
*
lxc_init_handler
(
const
char
*
name
,
extern
struct
lxc_handler
*
lxc_init_handler
(
const
char
*
name
,
struct
lxc_conf
*
conf
,
struct
lxc_conf
*
conf
,
const
char
*
lxcpath
);
const
char
*
lxcpath
);
extern
void
lxc_free_handler
(
struct
lxc_handler
*
handler
);
extern
int
lxc_init
(
const
char
*
name
,
struct
lxc_handler
*
handler
);
extern
int
lxc_init
(
const
char
*
name
,
struct
lxc_handler
*
handler
);
extern
void
lxc_fini
(
const
char
*
name
,
struct
lxc_handler
*
handler
);
extern
void
lxc_fini
(
const
char
*
name
,
struct
lxc_handler
*
handler
);
...
...
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