[11/14] forking: Introduce last_pid_mutex and helpers

Submitted by Kirill Tkhai on May 15, 2017, 1:05 p.m.

Details

Message ID 149485355777.681.12337613833186211500.stgit@localhost.localdomain
State New
Series "Refactor pid_ns helpers creation"
Headers show

Commit Message

Kirill Tkhai May 15, 2017, 1:05 p.m.
Introduce mutex for synchronization ns_last_pid file
on restore.

Signed-off-by: Kirill Tkhai <ktkhai@virtuozzo.com>
---
 criu/cr-restore.c       |    1 +
 criu/include/rst_info.h |   13 +++++++++++++
 2 files changed, 14 insertions(+)

Patch hide | download patch | download mbox

diff --git a/criu/cr-restore.c b/criu/cr-restore.c
index f516ab0d4..0f6dc23bc 100644
--- a/criu/cr-restore.c
+++ b/criu/cr-restore.c
@@ -2370,6 +2370,7 @@  int prepare_task_entries(void)
 	task_entries->nr_helpers = 0;
 	futex_set(&task_entries->start, CR_STATE_FAIL);
 	mutex_init(&task_entries->userns_sync_lock);
+	mutex_init(&task_entries->last_pid_mutex);
 
 	return 0;
 }
diff --git a/criu/include/rst_info.h b/criu/include/rst_info.h
index c3dbe2dd3..78b1f64d9 100644
--- a/criu/include/rst_info.h
+++ b/criu/include/rst_info.h
@@ -11,6 +11,7 @@  struct task_entries {
 	futex_t start;
 	atomic_t cr_err;
 	mutex_t userns_sync_lock;
+	mutex_t last_pid_mutex;
 };
 
 struct fdt {
@@ -64,4 +65,16 @@  struct rst_info {
 	void			*breakpoint;
 };
 
+extern struct task_entries *task_entries;
+
+static inline void lock_last_pid(void)
+{
+	mutex_lock(&task_entries->last_pid_mutex);
+}
+
+static inline void unlock_last_pid(void)
+{
+	mutex_unlock(&task_entries->last_pid_mutex);
+}
+
 #endif /* __CR_RST_INFO_H__ */