summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaniel Teske <daniel.teske@theqtcompany.com>2015-10-14 11:59:46 +0200
committerDaniel Teske <daniel.teske@theqtcompany.com>2015-10-14 16:00:21 +0000
commita027cbcd7051c634a51b6029dcb8a5b4bfe8b046 (patch)
tree4a38fee422165baa7bc9071aba7ee32c1f66c388
parent7c2761f1f014c43ad8105fc381690a65b213dcd8 (diff)
downloadqt-creator-a027cbcd7051c634a51b6029dcb8a5b4bfe8b046.tar.gz
Fix infinite QWaitCondition:wait() in discardFile*()
The original idea was that we would passively wait for another thread to clean up the locker, hence the check-sleep-loop. This was all dandy, except for *also* using the wait condition: this was a) mostly pointless (it would just avoid a few iterations of the wait loop) and b) buggy (if there were no other waiting threads, the actual reader thread wouldn't know that it needs to wake somebody up). As the passive waiting is ugly, we instead fix the use of the wait condition, and do away with the loop. Task-number: QTCREATORBUG-15181 Change-Id: I477dbe7cda49ceca9aa387910d94ad763a43012b Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@theqtcompany.com> Reviewed-by: Daniel Teske <daniel.teske@theqtcompany.com>
-rw-r--r--src/shared/proparser/qmakeparser.cpp27
1 files changed, 14 insertions, 13 deletions
diff --git a/src/shared/proparser/qmakeparser.cpp b/src/shared/proparser/qmakeparser.cpp
index 856b703e96..246afb1d48 100644
--- a/src/shared/proparser/qmakeparser.cpp
+++ b/src/shared/proparser/qmakeparser.cpp
@@ -63,13 +63,14 @@ void ProFileCache::discardFile(const QString &fileName)
if (it != parsed_files.end()) {
#ifdef PROPARSER_THREAD_SAFE
if (it->locker) {
- if (!it->locker->done)
+ if (!it->locker->done) {
+ ++it->locker->waiters;
it->locker->cond.wait(&mutex);
- do {
- lck.unlock();
- QThread::sleep(100);
- lck.relock();
- } while (it->locker);
+ if (!--it->locker->waiters) {
+ delete it->locker;
+ it->locker = 0;
+ }
+ }
}
#endif
if (it->pro)
@@ -90,13 +91,14 @@ void ProFileCache::discardFiles(const QString &prefix)
if (it.key().startsWith(prefix)) {
#ifdef PROPARSER_THREAD_SAFE
if (it->locker) {
- if (!it->locker->done)
+ if (!it->locker->done) {
+ ++it->locker->waiters;
it->locker->cond.wait(&mutex);
- do {
- lck.unlock();
- QThread::sleep(100);
- lck.relock();
- } while (it->locker);
+ if (!--it->locker->waiters) {
+ delete it->locker;
+ it->locker = 0;
+ }
+ }
}
#endif
if (it->pro)
@@ -107,7 +109,6 @@ void ProFileCache::discardFiles(const QString &prefix)
}
}
-
////////// Parser ///////////
#define fL1S(s) QString::fromLatin1(s)