summaryrefslogtreecommitdiffstats
path: root/common/resultprovider.h
diff options
context:
space:
mode:
authorChristian Mollekopf <chrigi_1@fastmail.fm>2017-03-07 12:04:47 +0100
committerChristian Mollekopf <chrigi_1@fastmail.fm>2017-03-07 12:04:47 +0100
commit4ecb10d3b1294d03578c28467c0f3759b3496e0b (patch)
treed8110a1109a0510746e9083b3272dda872dfe4a2 /common/resultprovider.h
parent88a0c750a80e6efb207877cac73144266e62d5ff (diff)
downloadsink-4ecb10d3b1294d03578c28467c0f3759b3496e0b.tar.gz
sink-4ecb10d3b1294d03578c28467c0f3759b3496e0b.zip
Resolved potential deadlock
When trying to reply to a mail from kube we ran into a deadlock. The initial result callback is called from the main thread, and that can thus directly lead to destruction of the emitter.
Diffstat (limited to 'common/resultprovider.h')
-rw-r--r--common/resultprovider.h10
1 files changed, 9 insertions, 1 deletions
diff --git a/common/resultprovider.h b/common/resultprovider.h
index a2ed0b5..d6feaf9 100644
--- a/common/resultprovider.h
+++ b/common/resultprovider.h
@@ -268,8 +268,9 @@ public:
268 268
269 void initialResultSetComplete(const DomainType &parent, bool replayedAll) 269 void initialResultSetComplete(const DomainType &parent, bool replayedAll)
270 { 270 {
271 QMutexLocker locker{&mMutex}; 271 //This callback is only ever called from the main thread, so we don't do any locking
272 if (initialResultSetCompleteHandler && guardOk()) { 272 if (initialResultSetCompleteHandler && guardOk()) {
273 //This can directly lead to our destruction and thus waitForMethodExecutionEnd
273 initialResultSetCompleteHandler(parent, replayedAll); 274 initialResultSetCompleteHandler(parent, replayedAll);
274 } 275 }
275 } 276 }
@@ -313,6 +314,13 @@ private:
313 std::function<void(void)> clearHandler; 314 std::function<void(void)> clearHandler;
314 315
315 std::function<void(const DomainType &parent)> mFetcher; 316 std::function<void(const DomainType &parent)> mFetcher;
317 /*
318 * This mutex is here to protect the emitter from getting destroyed while the producer-thread (ResultProvider) is calling into it,
319 * and vice-verca, to protect the producer thread from calling into a destroyed emitter.
320 *
321 * This is necessary because Emitter and ResultProvider have lifetimes managed by two different threads.
322 * The emitter lives in the application thread, and the resultprovider in the query thread.
323 */
316 QMutex mMutex; 324 QMutex mMutex;
317 bool mDone = false; 325 bool mDone = false;
318}; 326};