on xenial help sign in
On second thought, push that cancel up a layer to handle real liblightdm shutdown too
commitea7d230edd691d98e483eed6c69a23206a290956 authorMichael Terry <mike@mterry.name> dateWed 18 Jan 2017, 16:18 (10 years ago) parent1bab521
4 files changed+37−28
plugins/LightDM/Greeter.cpp+5 plugins/LightDM/IntegratedLightDM/liblightdm/Greeter.cpp+4−1 plugins/LightDM/IntegratedLightDM/liblightdm/GreeterPrivate.cpp+27−27 plugins/LightDM/IntegratedLightDM/liblightdm/GreeterPrivate.h+1
plugins/LightDM/Greeter.cpp+5
@@ -17,6 +17,7 @@
1717
1818#include "Greeter.h"
1919#include "GreeterPrivate.h"
20+#include <QCoreApplication>
2021#include <libintl.h>
2122
2223static Greeter *singleton = nullptr;
@@ -43,6 +44,10 @@ Greeter::Greeter(QObject* parent)
4344 connect(d->m_greeter, &QLightDM::Greeter::authenticationComplete,
4445 this, &Greeter::authenticationCompleteFilter);
4546
47+ // Don't get stuck waiting for PAM as we shut down.
48+ connect(QCoreApplication::instance(), &QCoreApplication::aboutToQuit,
49+ d->m_greeter, &QLightDM::Greeter::cancelAuthentication);
50+
4651 d->m_greeter->connectSync();
4752}
4853
plugins/LightDM/IntegratedLightDM/liblightdm/Greeter.cpp+4−1
@@ -146,7 +146,10 @@ void Greeter::authenticateRemote(const QString &session, const QString &username
146146}
147147
148148void Greeter::cancelAuthentication()
149−{}
149+{
150+ Q_D(Greeter);
151+ d->cancelAuthentication();
152+}
150153
151154void Greeter::setLanguage (const QString &language)
152155{
plugins/LightDM/IntegratedLightDM/liblightdm/GreeterPrivate.cpp+27−27
@@ -18,7 +18,6 @@
1818
1919#include "Greeter.h"
2020#include "GreeterPrivate.h"
21−#include <QCoreApplication>
2221#include <QFuture>
2322#include <QFutureInterface>
2423#include <QFutureWatcher>
@@ -51,10 +50,6 @@ public:
5150 {
5251 qRegisterMetaType<QLightDM::GreeterImpl::ResponseFuture>("QLightDM::GreeterImpl::ResponseFuture");
5352
54− // Don't get stuck waiting for PAM as we shut down.
55− connect(QCoreApplication::instance(), &QCoreApplication::aboutToQuit,
56− this, &GreeterImpl::cancelPam);
57−
5853 connect(&futureWatcher, &QFutureWatcher<int>::finished, this, &GreeterImpl::finishPam);
5954 connect(this, SIGNAL(showMessage(pam_handle *, QString, QLightDM::Greeter::MessageType)),
6055 this, SLOT(handleMessage(pam_handle *, QString, QLightDM::Greeter::MessageType)));
@@ -211,6 +206,28 @@ public Q_SLOTS:
211206 }
212207 }
213208
209+ void cancelPam()
210+ {
211+ if (pamHandle != nullptr) {
212+ QFuture<int> pamFuture = futureWatcher.future();
213+ pam_handle *handle = pamHandle;
214+ pamHandle = nullptr; // to disable normal finishPam() handling
215+ pamFuture.cancel();
216+
217+ // Note the empty loop, we just want to clear the futures queue.
218+ // Any further prompts from the pam thread will be immediately
219+ // responded to/dismissed in handlePrompt().
220+ while (respond(QString()));
221+
222+ // Now let signal/slot handling happen so the thread can finish
223+ while (!pamFuture.isFinished()) {
224+ QCoreApplication::processEvents();
225+ }
226+
227+ pam_end(handle, PAM_CONV_ERR);
228+ }
229+ }
230+
214231Q_SIGNALS:
215232 void showMessage(pam_handle *handle, QString text, QLightDM::Greeter::MessageType type);
216233 void showPrompt(pam_handle *handle, QString text, QLightDM::Greeter::PromptType type, QLightDM::GreeterImpl::ResponseFuture response);
@@ -251,28 +268,6 @@ private Q_SLOTS:
251268 Q_EMIT greeter->showPrompt(text, type);
252269 }
253270
254− void cancelPam()
255− {
256− if (pamHandle != nullptr) {
257− QFuture<int> pamFuture = futureWatcher.future();
258− pam_handle *handle = pamHandle;
259− pamHandle = nullptr; // to disable normal finishPam() handling
260− pamFuture.cancel();
261−
262− // Note the empty loop, we just want to clear the futures queue.
263− // Any further prompts from the pam thread will be immediately
264− // responded to/dismissed in handlePrompt().
265− while (respond(QString()));
266−
267− // Now let signal/slot handling happen so the thread can finish
268− while (!pamFuture.isFinished()) {
269− QCoreApplication::processEvents();
270− }
271−
272− pam_end(handle, PAM_CONV_ERR);
273− }
274− }
275−
276271private:
277272 Greeter *greeter;
278273 GreeterPrivate *greeterPrivate;
@@ -304,6 +299,11 @@ void GreeterPrivate::handleRespond(const QString &response)
304299 m_impl->respond(response);
305300}
306301
302+void GreeterPrivate::cancelAuthentication()
303+{
304+ m_impl->cancelPam();
305+}
306+
307307}
308308
309309#include "GreeterPrivate.moc"
plugins/LightDM/IntegratedLightDM/liblightdm/GreeterPrivate.h+1
@@ -38,6 +38,7 @@ public:
3838
3939 void handleAuthenticate();
4040 void handleRespond(const QString &response);
41+ void cancelAuthentication();
4142
4243protected:
4344 GreeterImpl *m_impl; // if the backend needs more private data