[X2Go-Commits] [x2goclient] 228/280: src/onmainwindow.cpp: terminate sshd more correctly.
git-admin at x2go.org
git-admin at x2go.org
Wed Jan 18 12:26:05 CET 2017
This is an automated email from the git hooks/post-receive script.
x2go pushed a commit to branch bugfix/osx
in repository x2goclient.
commit a0ee3c1848c6c4c1f23f3be42bd1d7dcc5aa06dc
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 211af30..d0b46f6 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -430,6 +430,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 b1d8bcb..0ec51ef 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