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
5befd767
Unverified
Commit
5befd767
authored
Oct 19, 2020
by
Christian Brauner
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
sync: log synchronization states
Signed-off-by:
Christian Brauner
<
christian.brauner@ubuntu.com
>
parent
35f0c46e
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
38 additions
and
1 deletion
+38
-1
sync.c
src/lxc/sync.c
+10
-1
sync.h
src/lxc/sync.h
+28
-0
No files found.
src/lxc/sync.c
View file @
5befd767
...
@@ -56,36 +56,44 @@ static int __sync_barrier(int fd, int sequence)
...
@@ -56,36 +56,44 @@ static int __sync_barrier(int fd, int sequence)
if
(
__sync_wake
(
fd
,
sequence
))
if
(
__sync_wake
(
fd
,
sequence
))
return
-
1
;
return
-
1
;
return
__sync_wait
(
fd
,
sequence
+
1
);
return
__sync_wait
(
fd
,
sequence
+
1
);
}
}
int
lxc_sync_barrier_parent
(
struct
lxc_handler
*
handler
,
int
sequence
)
int
lxc_sync_barrier_parent
(
struct
lxc_handler
*
handler
,
int
sequence
)
{
{
TRACE
(
"Child waking parent with sequence %s and waiting for sequence %s"
,
sync_to_string
(
sequence
),
sync_to_string
(
sequence
+
1
));
return
__sync_barrier
(
handler
->
sync_sock
[
0
],
sequence
);
return
__sync_barrier
(
handler
->
sync_sock
[
0
],
sequence
);
}
}
int
lxc_sync_barrier_child
(
struct
lxc_handler
*
handler
,
int
sequence
)
int
lxc_sync_barrier_child
(
struct
lxc_handler
*
handler
,
int
sequence
)
{
{
TRACE
(
"Parent waking child with sequence %s and waiting with sequence %s"
,
sync_to_string
(
sequence
),
sync_to_string
(
sequence
+
1
));
return
__sync_barrier
(
handler
->
sync_sock
[
1
],
sequence
);
return
__sync_barrier
(
handler
->
sync_sock
[
1
],
sequence
);
}
}
int
lxc_sync_wake_parent
(
struct
lxc_handler
*
handler
,
int
sequence
)
int
lxc_sync_wake_parent
(
struct
lxc_handler
*
handler
,
int
sequence
)
{
{
TRACE
(
"Child waking parent with sequence %s"
,
sync_to_string
(
sequence
));
return
__sync_wake
(
handler
->
sync_sock
[
0
],
sequence
);
return
__sync_wake
(
handler
->
sync_sock
[
0
],
sequence
);
}
}
int
lxc_sync_wait_parent
(
struct
lxc_handler
*
handler
,
int
sequence
)
int
lxc_sync_wait_parent
(
struct
lxc_handler
*
handler
,
int
sequence
)
{
{
TRACE
(
"Parent waiting for child with sequence %s"
,
sync_to_string
(
sequence
));
return
__sync_wait
(
handler
->
sync_sock
[
0
],
sequence
);
return
__sync_wait
(
handler
->
sync_sock
[
0
],
sequence
);
}
}
int
lxc_sync_wait_child
(
struct
lxc_handler
*
handler
,
int
sequence
)
int
lxc_sync_wait_child
(
struct
lxc_handler
*
handler
,
int
sequence
)
{
{
TRACE
(
"Child waiting for parent with sequence %s"
,
sync_to_string
(
sequence
));
return
__sync_wait
(
handler
->
sync_sock
[
1
],
sequence
);
return
__sync_wait
(
handler
->
sync_sock
[
1
],
sequence
);
}
}
int
lxc_sync_wake_child
(
struct
lxc_handler
*
handler
,
int
sequence
)
int
lxc_sync_wake_child
(
struct
lxc_handler
*
handler
,
int
sequence
)
{
{
TRACE
(
"Child waking parent with sequence %s"
,
sync_to_string
(
sequence
));
return
__sync_wake
(
handler
->
sync_sock
[
1
],
sequence
);
return
__sync_wake
(
handler
->
sync_sock
[
1
],
sequence
);
}
}
...
@@ -102,6 +110,7 @@ int lxc_sync_init(struct lxc_handler *handler)
...
@@ -102,6 +110,7 @@ int lxc_sync_init(struct lxc_handler *handler)
if
(
ret
<
0
)
if
(
ret
<
0
)
return
log_error_errno
(
-
1
,
errno
,
"Failed to make socket close-on-exec"
);
return
log_error_errno
(
-
1
,
errno
,
"Failed to make socket close-on-exec"
);
TRACE
(
"Initialized synchronization infrastructure"
);
return
0
;
return
0
;
}
}
...
...
src/lxc/sync.h
View file @
5befd767
...
@@ -20,6 +20,34 @@ enum {
...
@@ -20,6 +20,34 @@ enum {
LXC_SYNC_ERROR
=
-
1
/* Used to report errors from another process */
LXC_SYNC_ERROR
=
-
1
/* Used to report errors from another process */
};
};
static
inline
const
char
*
sync_to_string
(
int
state
)
{
switch
(
state
)
{
case
LXC_SYNC_STARTUP
:
return
"startup"
;
case
LXC_SYNC_CONFIGURE
:
return
"configure"
;
case
LXC_SYNC_POST_CONFIGURE
:
return
"post-configure"
;
case
LXC_SYNC_CGROUP
:
return
"cgroup"
;
case
LXC_SYNC_CGROUP_UNSHARE
:
return
"cgroup-unshare"
;
case
LXC_SYNC_CGROUP_LIMITS
:
return
"cgroup-limits"
;
case
LXC_SYNC_READY_START
:
return
"ready-start"
;
case
LXC_SYNC_RESTART
:
return
"restart"
;
case
LXC_SYNC_POST_RESTART
:
return
"post-restart"
;
case
LXC_SYNC_ERROR
:
return
"error"
;
default:
return
"invalid sync state"
;
}
}
__hidden
extern
int
lxc_sync_init
(
struct
lxc_handler
*
handler
);
__hidden
extern
int
lxc_sync_init
(
struct
lxc_handler
*
handler
);
__hidden
extern
void
lxc_sync_fini
(
struct
lxc_handler
*
);
__hidden
extern
void
lxc_sync_fini
(
struct
lxc_handler
*
);
__hidden
extern
void
lxc_sync_fini_parent
(
struct
lxc_handler
*
);
__hidden
extern
void
lxc_sync_fini_parent
(
struct
lxc_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