From 08f6f18af7ff7ed325045ca919a39074a18b7732 Mon Sep 17 00:00:00 2001 From: Marek Marczykowski Date: Fri, 7 Jun 2013 05:22:13 +0200 Subject: [PATCH] qrexec-lib: prevent deadlock on vchan It can happen that we already cleared libvchan_fd pending state via libvchan_wait, but data arrived later. This is especially true just after connection, when client send unsolicited notification to server, which can confuse it with some requested notification. --- qrexec-lib/txrx-vchan.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/qrexec-lib/txrx-vchan.c b/qrexec-lib/txrx-vchan.c index 6d372df..b3d252e 100644 --- a/qrexec-lib/txrx-vchan.c +++ b/qrexec-lib/txrx-vchan.c @@ -60,6 +60,8 @@ int wait_for_vchan_or_argfd_once(libvchan_t *ctrl, int max, fd_set * rdset, fd_s // the following will never block; we need to do this to // clear libvchan_fd pending state libvchan_wait(ctrl); + if (libvchan_data_ready(ctrl)) + return 1; return ret; }