[v4,12/19] files: Count inh_fd_max

Submitted by Kirill Tkhai on Jan. 10, 2018, 2:02 p.m.

Details

Message ID 151559293879.31108.17961982825698189931.stgit@localhost.localdomain
State Accepted
Series "Introduce custom per-task service fds placement"
Headers show

Commit Message

Kirill Tkhai Jan. 10, 2018, 2:02 p.m.
This patch counts maximum of inherited fds.
The value will be used in next patch.

Signed-off-by: Kirill Tkhai <ktkhai@virtuozzo.com>
---
 criu/files.c         |    5 +++++
 criu/include/files.h |    2 ++
 2 files changed, 7 insertions(+)

Patch hide | download patch | download mbox

diff --git a/criu/files.c b/criu/files.c
index 16f9a9169..8f6d50e92 100644
--- a/criu/files.c
+++ b/criu/files.c
@@ -1504,6 +1504,8 @@  struct inherit_fd {
 	dev_t inh_rdev;
 };
 
+int inh_fd_max = -1;
+
 /*
  * Return 1 if inherit fd has been closed or reused, 0 otherwise.
  *
@@ -1600,6 +1602,9 @@  int inherit_fd_add(int fd, char *key)
 	if (inh == NULL)
 		return -1;
 
+	if (fd > inh_fd_max)
+		inh_fd_max = fd;
+
 	inh->inh_id = key;
 	inh->inh_fd = fd;
 	inh->inh_dev = sbuf.st_dev;
diff --git a/criu/include/files.h b/criu/include/files.h
index 661a803e1..bd4ab8470 100644
--- a/criu/include/files.h
+++ b/criu/include/files.h
@@ -92,6 +92,8 @@  struct fdinfo_list_entry {
 	u8			fake:1;
 };
 
+extern int inh_fd_max;
+
 /* reports whether fd_a takes prio over fd_b */
 static inline int fdinfo_rst_prio(struct fdinfo_list_entry *fd_a, struct fdinfo_list_entry *fd_b)
 {