[X2Go-Commits] [x2goclient] 03/04: src/onmainwindow.{cpp, h}: don't error out directly if starting the X.Org Server failed on Windows.
git-admin at x2go.org
git-admin at x2go.org
Sat May 12 00:38:13 CEST 2018
This is an automated email from the git hooks/post-receive script.
x2go pushed a commit to branch master
in repository x2goclient.
commit 71b6eec557af9798b3b315592e241380fe6f0b90
Author: Mihai Moldovan <ionic at ionic.de>
Date: Fri May 11 23:20:25 2018 +0200
src/onmainwindow.{cpp,h}: don't error out directly if starting the X.Org Server failed on Windows.
Instead, try starting it three times, each time with a higher DISPLAY offset.
On busy client machines, several clients raced for the sockets
previously and often failed to start.
Also check if the server binary actually is still alive before doing the
TCP connection checks. A dead server won't be able to listen on a socket
in the first place.
---
debian/changelog | 7 ++++++
src/onmainwindow.cpp | 69 +++++++++++++++++++++++++++++++++++++++++++++++-----
src/onmainwindow.h | 3 ++-
3 files changed, 72 insertions(+), 7 deletions(-)
diff --git a/debian/changelog b/debian/changelog
index a45b70f..cfcbac6 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -50,6 +50,13 @@ x2goclient (4.1.2.0-0x2go1) UNRELEASED; urgency=medium
all addresses.
- src/onmainwindow.cpp: print out current DISPLAY value in debug log while
starting X.Org Server on Windows.
+ - src/onmainwindow.{cpp,h}: don't error out directly if starting the X.Org
+ Server failed on Windows. Instead, try starting it three times, each
+ time with a higher DISPLAY offset. On busy client machines, several
+ clients raced for the sockets previously and often failed to start. Also
+ check if the server binary actually is still alive before doing the TCP
+ connection checks. A dead server won't be able to listen on a socket in
+ the first place.
* x2goclient.spec:
- Remove plugin references.
* debian/rules:
diff --git a/src/onmainwindow.cpp b/src/onmainwindow.cpp
index 53cf24d..0e4e18b 100644
--- a/src/onmainwindow.cpp
+++ b/src/onmainwindow.cpp
@@ -171,6 +171,7 @@ ONMainWindow::ONMainWindow ( QWidget *parent ) :QMainWindow ( parent )
#ifdef Q_OS_WIN
xorg=0l;
xDisplay=0;
+ x_start_tries_ = 0;
#endif
if(X2goSettings::centralSettings())
@@ -9945,8 +9946,10 @@ void ONMainWindow::slotCheckXOrgLog()
xorgLogMutex.unlock();
}
-void ONMainWindow::startXOrg ()
+void ONMainWindow::startXOrg (std::size_t start_offset)
{
+ xDisplay += start_offset;
+
while ( isServerRunning ( 6000+xDisplay ) )
++xDisplay;
QString dispString;
@@ -10058,6 +10061,7 @@ void ONMainWindow::startXOrg ()
{
//check connection in slot and launch setWinServerReady
waitingForX=0;
+ x_start_tries_ += 1;
QTimer::singleShot(1000, this, SLOT(slotCheckXOrgConnection()));
}
// #endif
@@ -10066,6 +10070,35 @@ void ONMainWindow::startXOrg ()
void ONMainWindow::slotCheckXOrgConnection()
{
++waitingForX;
+
+ /* Before we try to connect to the socket, let's check if the server actually is still running. */
+ if (xorg->state () != QProcess::Running) {
+ /*
+ * Process died (crashed, terminated, whatever). We need to restart it, unless we already tried
+ * to do so multiple times unsuccessfully.
+ */
+ if (3 < x_start_tries_) {
+ x2goDebug << "Unable to start X.Org Server for three times, terminating.";
+
+ QMessageBox::critical (NULL, QString::null,
+ tr ("X.Org Server did not launch correctly after three tries.\n"
+ "Please check your installation."));
+
+ close ();
+
+ return;
+ }
+
+ x2goDebug << "Trying to re-start X.Org Server. Try count: " << x_start_tries_;
+
+ delete xorg;
+ xorg = NULL;
+
+ startXOrg (1);
+
+ return;
+ }
+
if (isServerRunning(6000+xDisplay))
{
x2goDebug<<"X.Org Server started on DISPLAY " << xDisplay << ".";
@@ -10076,11 +10109,35 @@ void ONMainWindow::slotCheckXOrgConnection()
{
if (waitingForX > 10)
{
- QMessageBox::critical (
- 0,QString::null,
- tr ( "Can't start X.Org Server.\n"
- "Please check your installation." ) );
- close();
+ /*
+ * Timeout reached. If we tried starting the X.Org Server less than three times,
+ * continue doing so (with a higher DISPLAY value).
+ * Otherwise error out.
+ */
+ if (3 >= x_start_tries_) {
+ /*
+ * Server might still be running here, but deleting the QProcess object
+ * should kill it.
+ */
+ x2goDebug << "Timeout reached waiting for the X.Org Server to open a listening TCP socket." << endl
+ << "Restarting on higher DISPLAY port. Try count: " << x_start_Tries;
+
+ xorg->terminate ();
+ delete xorg;
+ xorg = NULL;
+
+ startXOrg (1);
+
+ return;
+ {
+ else {
+ QMessageBox::critical (NULL, QString::null,
+ tr ("Can't start X.Org Server.\n"
+ "Please check your installation."));
+ close();
+
+ return;
+ }
}
else
{
diff --git a/src/onmainwindow.h b/src/onmainwindow.h
index 7272e66..d979c75 100644
--- a/src/onmainwindow.h
+++ b/src/onmainwindow.h
@@ -554,7 +554,7 @@ public:
QSize getEmbedAreaSize();
#ifdef Q_OS_WIN
static QString cygwinPath ( const QString& winPath );
- void startXOrg();
+ void startXOrg(std::size_t start_offset = 0);
static bool haveCygwinEntry();
static void removeCygwinEntry();
static QString U3DevicePath()
@@ -876,6 +876,7 @@ private:
QString xorgWidth;
QString xorgHeight;
int waitingForX;
+ std::size_t x_start_tries_;
QRect dispGeometry;
#endif
--
Alioth's /home/x2go-admin/maintenancescripts/git/hooks/post-receive-email on /srv/git/code.x2go.org/x2goclient.git
More information about the x2go-commits
mailing list