[CRIU] [PATCH 1/3] restore: Add add_post_prepare_cb_once helper

Cyrill Gorcunov gorcunov at openvz.org
Thu Mar 30 06:55:35 PDT 2017


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

diff --git a/criu/include/crtools.h b/criu/include/crtools.h
index efd84aedac62..7bdf0674366b 100644
--- a/criu/include/crtools.h
+++ b/criu/include/crtools.h
@@ -27,4 +27,17 @@ extern int cr_lazy_pages(bool daemon);
 extern int check_add_feature(char *arg);
 extern void pr_check_features(const char *offset, const char *sep, int width);
 
+#define add_post_prepare_cb_once(actor, data)			\
+	({							\
+		static int __cb_called = 0;			\
+		int ret = 0;					\
+								\
+		if (!__cb_called) {				\
+			ret = add_post_prepare_cb(actor, data);	\
+			__cb_called = 1;			\
+		}						\
+								\
+		ret;						\
+	})
+
 #endif /* __CR_CRTOOLS_H__ */
-- 
2.7.4



More information about the CRIU mailing list