[CRIU] [PATCH 2/2] tty: Don't forget to unblock tty peers

Cyrill Gorcunov gorcunov at openvz.org
Sat May 21 01:33:09 PDT 2016


When testing for queued data present on
peers we setup non-blocking mode over them
to obtain -EAGAIN if there is no data
at all, but I forget to restore former
mode on return, ie blocking read.

Reported-by: Andrey Vagin <avagin at virtuozzo.com>
Signed-off-by: Cyrill Gorcunov <gorcunov at openvz.org>
---
 criu/tty.c | 14 +++++++-------
 1 file changed, 7 insertions(+), 7 deletions(-)

diff --git a/criu/tty.c b/criu/tty.c
index 1a3442d3e103..bd048c3b863c 100644
--- a/criu/tty.c
+++ b/criu/tty.c
@@ -1917,18 +1917,18 @@ static int tty_do_dump_queued_data(struct tty_dump_info *dinfo)
  */
 static void __tty_do_writeback_queued_data(struct tty_dump_info *dinfo)
 {
-	if (write(dinfo->link->lfd, dinfo->tty_data,
-		  dinfo->tty_data_size) != dinfo->tty_data_size)
-		pr_perror("Can't writeback to tty (%#x)\n", dinfo->id);
+	if (dinfo->tty_data) {
+		if (write(dinfo->link->lfd, dinfo->tty_data,
+			  dinfo->tty_data_size) != dinfo->tty_data_size)
+			pr_perror("Can't writeback to tty (%#x)\n", dinfo->id);
+	}
 	tty_reblock(dinfo->link->id, dinfo->link->lfd, dinfo->link->flags);
 }
 
 static void tty_do_writeback_queued_data(struct tty_dump_info *dinfo)
 {
-	if (dinfo->tty_data)
-		__tty_do_writeback_queued_data(dinfo);
-	if (dinfo->link->tty_data)
-		__tty_do_writeback_queued_data(dinfo->link);
+	__tty_do_writeback_queued_data(dinfo);
+	__tty_do_writeback_queued_data(dinfo->link);
 }
 
 static void tty_dinfo_free(struct tty_dump_info *dinfo)
-- 
2.5.5



More information about the CRIU mailing list