[CRIU] [PATCH 03/16] Add add_post_prepare_cb_once helper

Cyrill Gorcunov gorcunov at openvz.org
Fri Dec 9 09:17:03 PST 2016


Signed-off-by: Cyrill Gorcunov <gorcunov at openvz.org>
---
 criu/include/crtools.h | 9 +++++++++
 1 file changed, 9 insertions(+)

diff --git a/criu/include/crtools.h b/criu/include/crtools.h
index efd84aedac62..50657c16ff1b 100644
--- a/criu/include/crtools.h
+++ b/criu/include/crtools.h
@@ -13,7 +13,16 @@
 extern int check_img_inventory(void);
 extern int write_img_inventory(InventoryEntry *he);
 extern int prepare_inventory(InventoryEntry *he);
+
 extern int add_post_prepare_cb(int (*actor)(void *data), void *data);
+#define add_post_prepare_cb_once(__actor, __data)				\
+	({									\
+		static int __called = 0;					\
+		int __ret = 0;							\
+		if (!__called)							\
+			__ret = add_post_prepare_cb((__actor), (__data));	\
+		__ret;								\
+	})
 extern bool deprecated_ok(char *what);
 extern int cr_dump_tasks(pid_t pid);
 extern int cr_pre_dump_tasks(pid_t pid);
-- 
2.7.4



More information about the CRIU mailing list