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

Submitted by Cyrill Gorcunov on May 21, 2016, 8:33 a.m.

Details

Message ID 1463819589-7963-3-git-send-email-gorcunov@openvz.org
State Accepted
Series "tty: Fix on queued data fetching"
Commit 718c9162c2399f3672754ad1a6ea76c80c86e3e8
Headers show

Commit Message

Cyrill Gorcunov May 21, 2016, 8:33 a.m.
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@virtuozzo.com>
Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
---
 criu/tty.c | 14 +++++++-------
 1 file changed, 7 insertions(+), 7 deletions(-)

Patch hide | download patch | download mbox

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)