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
c8dcf778
Unverified
Commit
c8dcf778
authored
Jan 20, 2018
by
Christian Brauner
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
coverity: #1426734
do not call close on bad fd Signed-off-by:
Christian Brauner
<
christian.brauner@ubuntu.com
>
parent
a49cad59
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
5 additions
and
10 deletions
+5
-10
monitor.c
src/lxc/monitor.c
+5
-10
No files found.
src/lxc/monitor.c
View file @
c8dcf778
...
@@ -209,7 +209,6 @@ int lxc_monitor_open(const char *lxcpath)
...
@@ -209,7 +209,6 @@ int lxc_monitor_open(const char *lxcpath)
int
fd
;
int
fd
;
size_t
retry
;
size_t
retry
;
size_t
len
;
size_t
len
;
int
ret
=
-
1
;
int
backoff_ms
[]
=
{
10
,
50
,
100
};
int
backoff_ms
[]
=
{
10
,
50
,
100
};
if
(
lxc_monitor_sock_name
(
lxcpath
,
&
addr
)
<
0
)
if
(
lxc_monitor_sock_name
(
lxcpath
,
&
addr
)
<
0
)
...
@@ -218,16 +217,16 @@ int lxc_monitor_open(const char *lxcpath)
...
@@ -218,16 +217,16 @@ int lxc_monitor_open(const char *lxcpath)
fd
=
socket
(
PF_UNIX
,
SOCK_STREAM
,
0
);
fd
=
socket
(
PF_UNIX
,
SOCK_STREAM
,
0
);
if
(
fd
<
0
)
{
if
(
fd
<
0
)
{
ERROR
(
"Failed to create socket: %s."
,
strerror
(
errno
));
ERROR
(
"Failed to create socket: %s."
,
strerror
(
errno
));
return
-
errno
;
return
-
1
;
}
}
len
=
strlen
(
&
addr
.
sun_path
[
1
]);
len
=
strlen
(
&
addr
.
sun_path
[
1
]);
DEBUG
(
"opening monitor socket %s with len %zu"
,
&
addr
.
sun_path
[
1
],
len
);
DEBUG
(
"opening monitor socket %s with len %zu"
,
&
addr
.
sun_path
[
1
],
len
);
if
(
len
>=
sizeof
(
addr
.
sun_path
)
-
1
)
{
if
(
len
>=
sizeof
(
addr
.
sun_path
)
-
1
)
{
errno
=
ENAMETOOLONG
;
errno
=
ENAMETOOLONG
;
ret
=
-
errno
;
ERROR
(
"name of monitor socket too long (%zu bytes): %s"
,
len
,
strerror
(
errno
));
ERROR
(
"name of monitor socket too long (%zu bytes): %s"
,
len
,
strerror
(
errno
));
goto
on_error
;
close
(
fd
);
return
-
1
;
}
}
for
(
retry
=
0
;
retry
<
sizeof
(
backoff_ms
)
/
sizeof
(
backoff_ms
[
0
]);
retry
++
)
{
for
(
retry
=
0
;
retry
<
sizeof
(
backoff_ms
)
/
sizeof
(
backoff_ms
[
0
]);
retry
++
)
{
...
@@ -239,16 +238,12 @@ int lxc_monitor_open(const char *lxcpath)
...
@@ -239,16 +238,12 @@ int lxc_monitor_open(const char *lxcpath)
}
}
if
(
fd
<
0
)
{
if
(
fd
<
0
)
{
ret
=
-
errno
;
ERROR
(
"Failed to connect to monitor socket: %s."
,
strerror
(
errno
));
ERROR
(
"Failed to connect to monitor socket: %s."
,
strerror
(
errno
));
goto
on_error
;
close
(
fd
);
return
-
1
;
}
}
return
fd
;
return
fd
;
on_error:
close
(
fd
);
return
ret
;
}
}
int
lxc_monitor_read_fdset
(
struct
pollfd
*
fds
,
nfds_t
nfds
,
struct
lxc_msg
*
msg
,
int
lxc_monitor_read_fdset
(
struct
pollfd
*
fds
,
nfds_t
nfds
,
struct
lxc_msg
*
msg
,
...
...
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