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
aee937d0
Commit
aee937d0
authored
Nov 29, 2016
by
Stéphane Graber
Committed by
GitHub
Nov 29, 2016
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #1336 from brauner/2016-11-29/use_clockgettime
state: use async signal safe fun in lxc_wait()
parents
f8110a89
940ef906
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
21 additions
and
21 deletions
+21
-21
state.c
src/lxc/state.c
+21
-21
No files found.
src/lxc/state.c
View file @
aee937d0
...
...
@@ -20,25 +20,27 @@
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
#include <errno.h>
#include <fcntl.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <fcntl.h>
#include <errno.h>
#include <time.h>
#include <unistd.h>
#include <sys/types.h>
#include <sys/socket.h>
#include <sys/file.h>
#include <sys/param.h>
#include <sys/socket.h>
#include <sys/stat.h>
#include <sys/
file
.h>
#include <sys/
types
.h>
#include "lxc.h"
#include "log.h"
#include "start.h"
#include "cgroup.h"
#include "monitor.h"
#include "commands.h"
#include "config.h"
#include "log.h"
#include "lxc.h"
#include "monitor.h"
#include "start.h"
lxc_log_define
(
lxc_state
,
lxc
);
...
...
@@ -103,11 +105,12 @@ static int fillwaitedstates(const char *strstates, int *states)
return
0
;
}
extern
int
lxc_wait
(
const
char
*
lxcname
,
const
char
*
states
,
int
timeout
,
const
char
*
lxcpath
)
extern
int
lxc_wait
(
const
char
*
lxcname
,
const
char
*
states
,
int
timeout
,
const
char
*
lxcpath
)
{
struct
lxc_msg
msg
;
int
state
,
ret
;
int
s
[
MAX_STATE
]
=
{
},
fd
;
int
s
[
MAX_STATE
]
=
{
0
},
fd
;
if
(
fillwaitedstates
(
states
,
s
))
return
-
1
;
...
...
@@ -133,16 +136,16 @@ extern int lxc_wait(const char *lxcname, const char *states, int timeout, const
}
for
(;;)
{
int
elapsed_time
,
curtime
=
0
;
struct
time
val
tv
;
int
64_t
elapsed_time
,
curtime
=
0
;
struct
time
spec
tspec
;
int
stop
=
0
;
int
retval
;
if
(
timeout
!=
-
1
)
{
retval
=
gettimeofday
(
&
tv
,
NULL
);
retval
=
clock_gettime
(
CLOCK_REALTIME
,
&
tspec
);
if
(
retval
)
goto
out_close
;
curtime
=
t
v
.
tv_sec
;
curtime
=
t
spec
.
tv_sec
;
}
if
(
lxc_monitor_read_timeout
(
fd
,
&
msg
,
timeout
)
<
0
)
{
/* try again if select interrupted by signal */
...
...
@@ -151,10 +154,10 @@ extern int lxc_wait(const char *lxcname, const char *states, int timeout, const
}
if
(
timeout
!=
-
1
)
{
retval
=
gettimeofday
(
&
tv
,
NULL
);
retval
=
clock_gettime
(
CLOCK_REALTIME
,
&
tspec
);
if
(
retval
)
goto
out_close
;
elapsed_time
=
t
v
.
tv_sec
-
curtime
;
elapsed_time
=
t
spec
.
tv_sec
-
curtime
;
if
(
timeout
-
elapsed_time
<=
0
)
stop
=
1
;
timeout
-=
elapsed_time
;
...
...
@@ -170,11 +173,8 @@ extern int lxc_wait(const char *lxcname, const char *states, int timeout, const
switch
(
msg
.
type
)
{
case
lxc_msg_state
:
if
(
msg
.
value
<
0
||
msg
.
value
>=
MAX_STATE
)
{
ERROR
(
"Receive an invalid state number '%d'"
,
msg
.
value
);
if
(
msg
.
value
<
0
||
msg
.
value
>=
MAX_STATE
)
goto
out_close
;
}
if
(
s
[
msg
.
value
])
{
ret
=
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