[education/rkward/experimental/handshake] rkward/rbackend: Experimental: Another attempt at stabilizing handshake on Windows.

Thomas Friedrichsmeier null at kde.org
Mon May 9 20:02:05 BST 2022


Git commit 6b2b3d4a34c9c2441378f561c31bbae7fc35bc94 by Thomas Friedrichsmeier.
Committed on 09/05/2022 at 19:01.
Pushed by tfry into branch 'experimental/handshake'.

Experimental: Another attempt at stabilizing handshake on Windows.

M  +9    -2    rkward/rbackend/rkbackendtransmitter.cpp
M  +0    -3    rkward/rbackend/rkrbackendprotocol_backend.cpp

https://invent.kde.org/education/rkward/commit/6b2b3d4a34c9c2441378f561c31bbae7fc35bc94

diff --git a/rkward/rbackend/rkbackendtransmitter.cpp b/rkward/rbackend/rkbackendtransmitter.cpp
index bfb7e66a..da89ddd0 100644
--- a/rkward/rbackend/rkbackendtransmitter.cpp
+++ b/rkward/rbackend/rkbackendtransmitter.cpp
@@ -11,6 +11,8 @@ SPDX-License-Identifier: GPL-2.0-or-later
 
 #include <QLocalSocket>
 
+#include <iostream>
+
 #include "../version.h"
 #include "../debug.h"
 
@@ -45,8 +47,13 @@ void RKRBackendTransmitter::run () {
 	QLocalSocket* con = new QLocalSocket (this);
 	con->connectToServer (servername);
 	setConnection (con);
-	
-	if (!connection->waitForConnected ()) handleTransmissionError ("Could not connect: " + connection->errorString ());
+
+	int timeout = 0;
+	do {
+		std::cout << token.toLocal8Bit().data() << "\n";
+		std::cout.flush();
+	} while (!connection->waitForConnected(1000) && (++timeout < 20));
+	if (timeout >= 20) handleTransmissionError("Could not connect: " + connection->errorString());
 	// handshake
 	connection->write (token.toLocal8Bit ().data ());
 	connection->write ("\n");
diff --git a/rkward/rbackend/rkrbackendprotocol_backend.cpp b/rkward/rbackend/rkrbackendprotocol_backend.cpp
index c1dec369..64c2c586 100644
--- a/rkward/rbackend/rkrbackendprotocol_backend.cpp
+++ b/rkward/rbackend/rkrbackendprotocol_backend.cpp
@@ -106,9 +106,6 @@ SPDX-License-Identifier: GPL-2.0-or-later
 		// a simple security token to send to the frontend to make sure that it is really talking to the backend process that it started in the local socket connection.
 		// this token is sent both via stdout and the local socket connection. The frontend simply compares both values.
 		QString token = QUuid::createUuid ().toString ();
-		std::cout << token.toLocal8Bit ().data () << "\n";
-		std::cout << token.toLocal8Bit ().data () << "\n";
-		std::cout.flush ();
 
 		RKRBackendTransmitter transmitter (servername, token);
 		RKRBackendProtocolBackend backend (data_dir, rkd_server_name);


More information about the rkward-tracker mailing list