[X2Go-Commits] [x2goclient] 04/04: src/onmainwindow.cpp: terminate sshd more correctly.
git-admin at x2go.org
git-admin at x2go.org
Fri Sep 23 08:22:17 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 b84ca8cf97ae286a91eac681deaadfc6ed2309b1
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 4c6fb34..2962e12 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 ().
-- X2Go Release Manager <git-admin at x2go.org> Mon, 19 Sep 2016 09:07:07 +0200
diff --git a/src/onmainwindow.cpp b/src/onmainwindow.cpp
index 8792c89..d4c70a8 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