From b0e7af2972b82364f8ca95fef8031cbd018d54e0 Mon Sep 17 00:00:00 2001 From: Christian Mollekopf Date: Wed, 29 Apr 2015 01:11:40 +0200 Subject: Avoid starting the resource for shutdown. --- common/clientapi.cpp | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) (limited to 'common/clientapi.cpp') diff --git a/common/clientapi.cpp b/common/clientapi.cpp index c6f5582..5cb3b69 100644 --- a/common/clientapi.cpp +++ b/common/clientapi.cpp @@ -2,6 +2,7 @@ #include "clientapi.h" #include "resourceaccess.h" #include "commands.h" +#include "log.h" namespace async { @@ -39,10 +40,19 @@ QByteArray getTypeName() void Store::shutdown(const QByteArray &identifier) { - Akonadi2::ResourceAccess resourceAccess(identifier); - //FIXME this starts the resource, just to shut it down again if it's not running in the first place. - resourceAccess.open(); - resourceAccess.sendCommand(Akonadi2::Commands::ShutdownCommand).exec().waitForFinished(); + Trace() << "shutdown"; + ResourceAccess::connectToServer(identifier).then>([identifier](const QSharedPointer &socket, Async::Future &future) { + //We can't currently reuse the socket + socket->close(); + auto resourceAccess = QSharedPointer::create(identifier); + resourceAccess->open(); + resourceAccess->sendCommand(Akonadi2::Commands::ShutdownCommand).then([&future, resourceAccess]() { + future.setFinished(); + }).exec(); + }, + [](int, const QString &) { + //Resource isn't started, nothing to shutdown + }).exec().waitForFinished(); } } // namespace Akonadi2 -- cgit v1.2.3