2
0
mirror of https://github.com/checkpoint-restore/criu synced 2025-08-30 13:58:34 +00:00

Explain how an inherit fd can be reused.

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@google.com>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
This commit is contained in:
Saied Kazemi
2014-12-19 18:50:39 +03:00
committed by Pavel Emelyanov
parent 4ea1eaa6cb
commit b2e6690409

View File

@@ -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)
{