[CRIU] [PATCH v3 00/26] Rework file opening scheme to make it asynchronous

Kirill Tkhai ktkhai at virtuozzo.com
Wed Dec 7 02:07:44 PST 2016


On 05.12.2016 17:07, Kirill Tkhai wrote:
> This series rework file opening scheme. Currently, we have 4 stages of opening:
> 1)prepare
> 2)create
> 3)receive
> 4)post_create

[25/26] has a problem with receive_tty() retval. This fix may be merged with it together.

[PATCH]tty: Fix retval manipulations in receive_tty()

receive_tty() may return ORV_AGAIN (== 1), while tty_open()
interprets it as fd. Merge new_fd assignment to receive_tty()
and return this function result directly to fix that.

Also, return ORV_ERR in case of rst_file_params() fail.

Signed-off-by: Kirill Tkhai <ktkhai at virtuozzo.com>

diff --git a/criu/tty.c b/criu/tty.c
index 9f8c5e1..bd6370b 100644
--- a/criu/tty.c
+++ b/criu/tty.c
@@ -912,7 +912,7 @@ static int pty_open_slaves(struct tty_info *info)
 	return ret;
 }
 
-static int receive_tty(struct tty_info *info)
+static int receive_tty(struct tty_info *info, int *new_fd)
 {
 	struct fdinfo_list_entry *fle;
 	int fd, ret;
@@ -928,10 +928,13 @@ static int receive_tty(struct tty_info *info)
 		return ret;
 	}
 
-	if (rst_file_params(fd, info->tfe->fown, info->tfe->flags))
+	if (rst_file_params(fd, info->tfe->fown, info->tfe->flags) < 0) {
 		close_safe(&fd);
+		return ORV_ERR;
+	}
 
-	return fd;
+	*new_fd = fd;
+	return ORV_OK;
 }
 
 static int pty_open_unpaired_slave(struct file_desc *d, struct tty_info *slave)
@@ -1102,7 +1105,7 @@ static int tty_open(struct file_desc *d, int *new_fd)
 	tty_show_pty_info("open", info);
 
 	if (!info->create)
-		ret = receive_tty(info);
+		return receive_tty(info, new_fd);
 	else if (is_pty(info->driver) && !tty_is_master(info))
 		ret = pty_open_unpaired_slave(d, info);
 	else



More information about the CRIU mailing list