diff options
author | Christian Mollekopf <chrigi_1@fastmail.fm> | 2015-04-29 01:11:40 +0200 |
---|---|---|
committer | Christian Mollekopf <chrigi_1@fastmail.fm> | 2015-04-29 01:11:40 +0200 |
commit | b0e7af2972b82364f8ca95fef8031cbd018d54e0 (patch) | |
tree | 3f6f1aad825e1b02aa5d9a882730c1be85ba5023 /common | |
parent | 3c0e79b1e9088e3b55f65fe5cc440ffb08dfde0a (diff) | |
download | sink-b0e7af2972b82364f8ca95fef8031cbd018d54e0.tar.gz sink-b0e7af2972b82364f8ca95fef8031cbd018d54e0.zip |
Avoid starting the resource for shutdown.
Diffstat (limited to 'common')
-rw-r--r-- | common/clientapi.cpp | 18 | ||||
-rw-r--r-- | common/resourceaccess.cpp | 6 | ||||
-rw-r--r-- | common/resourceaccess.h | 4 |
3 files changed, 22 insertions, 6 deletions
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 @@ | |||
2 | #include "clientapi.h" | 2 | #include "clientapi.h" |
3 | #include "resourceaccess.h" | 3 | #include "resourceaccess.h" |
4 | #include "commands.h" | 4 | #include "commands.h" |
5 | #include "log.h" | ||
5 | 6 | ||
6 | namespace async | 7 | namespace async |
7 | { | 8 | { |
@@ -39,10 +40,19 @@ QByteArray getTypeName<AkonadiResource>() | |||
39 | 40 | ||
40 | void Store::shutdown(const QByteArray &identifier) | 41 | void Store::shutdown(const QByteArray &identifier) |
41 | { | 42 | { |
42 | Akonadi2::ResourceAccess resourceAccess(identifier); | 43 | Trace() << "shutdown"; |
43 | //FIXME this starts the resource, just to shut it down again if it's not running in the first place. | 44 | ResourceAccess::connectToServer(identifier).then<void, QSharedPointer<QLocalSocket>>([identifier](const QSharedPointer<QLocalSocket> &socket, Async::Future<void> &future) { |
44 | resourceAccess.open(); | 45 | //We can't currently reuse the socket |
45 | resourceAccess.sendCommand(Akonadi2::Commands::ShutdownCommand).exec().waitForFinished(); | 46 | socket->close(); |
47 | auto resourceAccess = QSharedPointer<Akonadi2::ResourceAccess>::create(identifier); | ||
48 | resourceAccess->open(); | ||
49 | resourceAccess->sendCommand(Akonadi2::Commands::ShutdownCommand).then<void>([&future, resourceAccess]() { | ||
50 | future.setFinished(); | ||
51 | }).exec(); | ||
52 | }, | ||
53 | [](int, const QString &) { | ||
54 | //Resource isn't started, nothing to shutdown | ||
55 | }).exec().waitForFinished(); | ||
46 | } | 56 | } |
47 | 57 | ||
48 | } // namespace Akonadi2 | 58 | } // namespace Akonadi2 |
diff --git a/common/resourceaccess.cpp b/common/resourceaccess.cpp index c6d701d..28aaf2e 100644 --- a/common/resourceaccess.cpp +++ b/common/resourceaccess.cpp | |||
@@ -84,7 +84,7 @@ ResourceAccess::Private::Private(const QByteArray &name, ResourceAccess *q) | |||
84 | } | 84 | } |
85 | 85 | ||
86 | //Connects to server and returns connected socket on success | 86 | //Connects to server and returns connected socket on success |
87 | static Async::Job<QSharedPointer<QLocalSocket> > connectToServer(const QByteArray &identifier) | 87 | Async::Job<QSharedPointer<QLocalSocket> > ResourceAccess::connectToServer(const QByteArray &identifier) |
88 | { | 88 | { |
89 | auto s = QSharedPointer<QLocalSocket>::create(); | 89 | auto s = QSharedPointer<QLocalSocket>::create(); |
90 | return Async::start<QSharedPointer<QLocalSocket> >([identifier, s](Async::Future<QSharedPointer<QLocalSocket> > &future) { | 90 | return Async::start<QSharedPointer<QLocalSocket> >([identifier, s](Async::Future<QSharedPointer<QLocalSocket> > &future) { |
@@ -161,7 +161,9 @@ ResourceAccess::ResourceAccess(const QByteArray &resourceName, QObject *parent) | |||
161 | 161 | ||
162 | ResourceAccess::~ResourceAccess() | 162 | ResourceAccess::~ResourceAccess() |
163 | { | 163 | { |
164 | 164 | if (!d->resultHandler.isEmpty()) { | |
165 | Warning() << "Left jobs running while shutting down ResourceAccess"; | ||
166 | } | ||
165 | } | 167 | } |
166 | 168 | ||
167 | QByteArray ResourceAccess::resourceName() const | 169 | QByteArray ResourceAccess::resourceName() const |
diff --git a/common/resourceaccess.h b/common/resourceaccess.h index dc7640d..c16a9d2 100644 --- a/common/resourceaccess.h +++ b/common/resourceaccess.h | |||
@@ -46,6 +46,10 @@ public: | |||
46 | Async::Job<void> sendCommand(int commandId); | 46 | Async::Job<void> sendCommand(int commandId); |
47 | Async::Job<void> sendCommand(int commandId, flatbuffers::FlatBufferBuilder &fbb); | 47 | Async::Job<void> sendCommand(int commandId, flatbuffers::FlatBufferBuilder &fbb); |
48 | Async::Job<void> synchronizeResource(bool remoteSync, bool localSync); | 48 | Async::Job<void> synchronizeResource(bool remoteSync, bool localSync); |
49 | /** | ||
50 | * Tries to connect to server, and returns a connected socket on success. | ||
51 | */ | ||
52 | static Async::Job<QSharedPointer<QLocalSocket> > connectToServer(const QByteArray &identifier); | ||
49 | 53 | ||
50 | public Q_SLOTS: | 54 | public Q_SLOTS: |
51 | void open(); | 55 | void open(); |