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
44552fb2
Unverified
Commit
44552fb2
authored
Nov 25, 2017
by
Christian Brauner
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
commands: tell mainloop to reap client fd on error
This is the proper way to handle errors. Signed-off-by:
Christian Brauner
<
christian.brauner@ubuntu.com
>
parent
f8bdb6dc
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
21 additions
and
6 deletions
+21
-6
commands.c
src/lxc/commands.c
+20
-6
commands_utils.c
src/lxc/commands_utils.c
+1
-0
No files found.
src/lxc/commands.c
View file @
44552fb2
...
@@ -922,8 +922,8 @@ int lxc_cmd_add_state_client(const char *name, const char *lxcpath,
...
@@ -922,8 +922,8 @@ int lxc_cmd_add_state_client(const char *name, const char *lxcpath,
state
=
PTR_TO_INT
(
cmd
.
rsp
.
data
);
state
=
PTR_TO_INT
(
cmd
.
rsp
.
data
);
if
(
state
<
MAX_STATE
)
{
if
(
state
<
MAX_STATE
)
{
TRACE
(
"Container is already in requested state %s"
,
TRACE
(
"Container is already in requested state %s"
,
lxc_state2str
(
state
));
lxc_state2str
(
state
)
);
close
(
cmd
.
rsp
.
ret
);
return
state
;
return
state
;
}
}
...
@@ -935,21 +935,35 @@ int lxc_cmd_add_state_client(const char *name, const char *lxcpath,
...
@@ -935,21 +935,35 @@ int lxc_cmd_add_state_client(const char *name, const char *lxcpath,
static
int
lxc_cmd_add_state_client_callback
(
int
fd
,
struct
lxc_cmd_req
*
req
,
static
int
lxc_cmd_add_state_client_callback
(
int
fd
,
struct
lxc_cmd_req
*
req
,
struct
lxc_handler
*
handler
)
struct
lxc_handler
*
handler
)
{
{
int
ret
;
struct
lxc_cmd_rsp
rsp
=
{
0
};
struct
lxc_cmd_rsp
rsp
=
{
0
};
if
(
req
->
datalen
<
0
)
if
(
req
->
datalen
<
0
)
return
-
1
;
goto
reap_client_fd
;
if
(
req
->
datalen
>
(
sizeof
(
lxc_state_t
)
*
MAX_STATE
))
if
(
req
->
datalen
>
(
sizeof
(
lxc_state_t
)
*
MAX_STATE
))
return
-
1
;
goto
reap_client_fd
;
if
(
!
req
->
data
)
if
(
!
req
->
data
)
return
-
1
;
goto
reap_client_fd
;
rsp
.
ret
=
lxc_add_state_client
(
fd
,
handler
,
(
lxc_state_t
*
)
req
->
data
);
rsp
.
ret
=
lxc_add_state_client
(
fd
,
handler
,
(
lxc_state_t
*
)
req
->
data
);
if
(
rsp
.
ret
<
0
)
goto
reap_client_fd
;
rsp
.
data
=
INT_TO_PTR
(
rsp
.
ret
);
rsp
.
data
=
INT_TO_PTR
(
rsp
.
ret
);
return
lxc_cmd_rsp_send
(
fd
,
&
rsp
);
ret
=
lxc_cmd_rsp_send
(
fd
,
&
rsp
);
if
(
ret
<
0
)
goto
reap_client_fd
;
return
0
;
reap_client_fd:
/* Special indicator to lxc_cmd_handler() to close the fd and do related
* cleanup.
*/
return
1
;
}
}
int
lxc_cmd_console_log
(
const
char
*
name
,
const
char
*
lxcpath
,
int
lxc_cmd_console_log
(
const
char
*
name
,
const
char
*
lxcpath
,
...
...
src/lxc/commands_utils.c
View file @
44552fb2
...
@@ -220,6 +220,7 @@ int lxc_add_state_client(int state_client_fd, struct lxc_handler *handler,
...
@@ -220,6 +220,7 @@ int lxc_add_state_client(int state_client_fd, struct lxc_handler *handler,
}
else
{
}
else
{
process_unlock
();
process_unlock
();
free
(
newclient
);
free
(
newclient
);
free
(
tmplist
);
return
state
;
return
state
;
}
}
...
...
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