From d6f0cfcbadf0bc6fa03bcf67c35f8e886a315c80 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marek=20Marczykowski-G=C3=B3recki?= Date: Thu, 16 Apr 2015 15:47:54 +0200 Subject: [PATCH] qrexec: fix waiting for qrexec-agent data connection In case of vchan server libvchan_is_open() returns VCHAN_WAITING (2) when client is not yet connected. --- qrexec/qrexec-client.c | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/qrexec/qrexec-client.c b/qrexec/qrexec-client.c index 2fbfaa7..d909e39 100644 --- a/qrexec/qrexec-client.c +++ b/qrexec/qrexec-client.c @@ -598,10 +598,10 @@ int main(int argc, char **argv) else { data_vchan = libvchan_server_init(data_domain, data_port, VCHAN_BUFFER_SIZE, VCHAN_BUFFER_SIZE); - while (data_vchan && !libvchan_is_open(data_vchan)) + while (data_vchan && libvchan_is_open(data_vchan) == VCHAN_WAITING) libvchan_wait(data_vchan); } - if (!data_vchan) { + if (!data_vchan || !libvchan_is_open(data_vchan)) { fprintf(stderr, "Failed to open data vchan connection\n"); do_exit(1); } @@ -635,8 +635,12 @@ int main(int argc, char **argv) fprintf(stderr, "Failed to start data vchan server\n"); do_exit(1); } - while (!libvchan_is_open(data_vchan)) + while (libvchan_is_open(data_vchan) == VCHAN_WAITING) libvchan_wait(data_vchan); + if (!libvchan_is_open(data_vchan)) { + fprintf(stderr, "Failed to open data vchan connection\n"); + do_exit(1); + } if (handle_agent_handshake(data_vchan, 0) < 0) do_exit(1); select_loop(data_vchan);