[X2Go-Commits] [x2goclient] 228/239: src/onmainwindow.cpp: terminate sshd more correctly.

git-admin at x2go.org git-admin at x2go.org
Mon Oct 24 23:28:03 CEST 2016


This is an automated email from the git hooks/post-receive script.

x2go pushed a commit to branch bugfix/osx
in repository x2goclient.

commit 4e19f6faa7ca460d73a265581216bef7e8955b83
Author: Mihai Moldovan <ionic at ionic.de>
Date:   Fri Sep 23 08:21:13 2016 +0200

    src/onmainwindow.cpp: terminate sshd more correctly.
    
    First via terminate (), then wait up to 5 seconds, then via kill ().
---
 debian/changelog     |    2 ++
 src/onmainwindow.cpp |   32 +++++++++++++++++++++++++++-----
 2 files changed, 29 insertions(+), 5 deletions(-)

diff --git a/debian/changelog b/debian/changelog
index d8b04fa..b84ae08 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -404,6 +404,8 @@ x2goclient (4.0.5.3-0x2go1) UNRELEASED; urgency=medium
       went into running state earlier.
     - src/onmainwindow.cpp: uppercase key type in debug output and comment
       string in generateKey ().
+    - src/onmainwindow.cpp: terminate sshd more correctly. First via terminate
+      (), then wait up to 5 seconds, then via kill ().
 
   [ Bernard Cafarelli ]
   * New upstream version (4.0.5.3):
diff --git a/src/onmainwindow.cpp b/src/onmainwindow.cpp
index 22bb3cd..653db50 100644
--- a/src/onmainwindow.cpp
+++ b/src/onmainwindow.cpp
@@ -1515,11 +1515,33 @@ void ONMainWindow::closeClient()
 #endif /* defined (Q_OS_DARWIN) || defined (Q_OS_WIN) */
 
 #ifndef Q_OS_WIN
-    if (sshd)
-    {
-        x2goDebug<<"Terminating the OpenSSH server ...";
-        sshd->terminate();
-        x2goDebug<<"Terminated the OpenSSH server.";
+    if (sshd) {
+        x2goDebug << "Terminating the OpenSSH server ...";
+        sshd->terminate ();
+
+        /* Allow sshd a grace time of 5 seconds to terminate. */
+        QTime sleep_time = QTime::currentTime ().addSecs (5);
+        bool killed = false;
+        while (QTime::currentTime () < sleep_time) {
+            if (QProcess::NotRunning == sshd->state ()) {
+                killed = true;
+                break;
+            }
+
+            QCoreApplication::processEvents (QEventLoop::AllEvents, 100);
+        }
+
+        if (!killed) {
+            /* Grace period over, force termination. */
+            sshd->kill ();
+
+            if (!(sshd->waitForFinished (500))) {
+                x2goWarningf (8) << "OpenSSH Server failed to terminate in time "
+                                    " and the kill command timed out.";
+            }
+        }
+
+        x2goDebug << "Terminated the OpenSSH server.";
         delete sshd;
     }
 #endif /* !defined (Q_OS_WIN) */

--
Alioth's /srv/git/code.x2go.org/x2goclient.git//..//_hooks_/post-receive-email on /srv/git/code.x2go.org/x2goclient.git


More information about the x2go-commits mailing list