[CRIU] [PATCH] Explain how an inherit fd can be reused.

Saied Kazemi saied at google.com
Thu Dec 11 10:44:49 PST 2014


Add comment to inherit_fd_reused() explaining how an inherit fd may be
closed or reused outside the inherit fd logic.

Signed-off-by: Saied Kazemi <saied at google.com>
---
 files.c | 9 +++++++++
 1 file changed, 9 insertions(+)

diff --git a/files.c b/files.c
index e2c4aa3..55cbac8 100644
--- a/files.c
+++ b/files.c
@@ -1227,6 +1227,15 @@ struct inherit_fd {
 
 /*
  * Return 1 if inherit fd has been closed or reused, 0 otherwise.
+ *
+ * Some parts of the file restore engine can close an inherit fd
+ * explicitly by close() or implicitly by dup2() to reuse that descriptor.
+ * In some specific functions (for example, send_fd_to_self()), we
+ * check for clashes at the beginning of the function and, therefore,
+ * these specific functions will not reuse an inherit fd.  However, to
+ * avoid adding a ton of clash detect and resolve code everywhere we close()
+ * and/or dup2(), we just make sure that when we're dup()ing or close()ing
+ * our inherit fd we're still dealing with the same fd that we inherited.
  */
 static int inherit_fd_reused(struct inherit_fd *inh)
 {
-- 
2.2.0.rc0.207.ga3a616c



More information about the CRIU mailing list