Skip to content

Commit

Permalink
fix: [server] exit server when PrepareForShutdown emitted.
Browse files Browse the repository at this point in the history
to make server exit before udisksd when shutdown/reboot.

Log: as title.
  • Loading branch information
itsXuSt committed May 7, 2024
1 parent 4220052 commit ec3fe31
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 0 deletions.
16 changes: 16 additions & 0 deletions src/plugins/server/core/serverplugin-core/core.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,14 @@ bool Core::start()
DevMngIns->startMonitor();
}

bool connected = QDBusConnection::systemBus().connect("org.freedesktop.login1",
"/org/freedesktop/login1",
"org.freedesktop.login1.Manager",
"PrepareForShutdown",
this,
SLOT(exitOnShutdown(bool)));
fmDebug() << "login1::PrepareForShutdown connected:" << connected;

return true;
}

Expand Down Expand Up @@ -102,4 +110,12 @@ void Core::initOperationsDBus(QDBusConnection *connection)
}
}

void Core::exitOnShutdown(bool shutdown)

Check warning on line 113 in src/plugins/server/core/serverplugin-core/core.cpp

View workflow job for this annotation

GitHub Actions / cppcheck

The function 'exitOnShutdown' is never used.
{
if (shutdown) {
qWarning() << "PrepareForShutdown is emitted, exit...";
qApp->exit(0);
}
}

SERVERPCORE_END_NAMESPACE
3 changes: 3 additions & 0 deletions src/plugins/server/core/serverplugin-core/core.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,9 @@ class Core : public DPF_NAMESPACE::Plugin
void initDeviceDBus(QDBusConnection *connection);
void initOperationsDBus(QDBusConnection *connection);

private Q_SLOTS:
void exitOnShutdown(bool);

private:
QScopedPointer<DeviceManagerDBus> deviceManager;
QScopedPointer<OperationsStackManagerDbus> operationsStackManager;
Expand Down

0 comments on commit ec3fe31

Please sign in to comment.