summaryrefslogtreecommitdiffstats
path: root/smdirwatcher.cpp
diff options
context:
space:
mode:
authorArno <am@disconnect.de>2013-08-27 12:52:03 +0200
committerArno <am@disconnect.de>2013-08-27 12:52:03 +0200
commitdbfc4f7bf395bf20aa21058372d47d17d040f553 (patch)
tree6ee4b9c182874cbf5e9886ee387f4de22102468d /smdirwatcher.cpp
parent7a87f1a85527927499325cb9b2a0b9dce8105935 (diff)
downloadSheMov-dbfc4f7bf395bf20aa21058372d47d17d040f553.tar.gz
SheMov-dbfc4f7bf395bf20aa21058372d47d17d040f553.tar.bz2
SheMov-dbfc4f7bf395bf20aa21058372d47d17d040f553.zip
Don't enqueue equal events twice
Fix a race condition. This is what happened: A file gets closes shortly after the last write, so it gets enqueued twice. Since QQueue is a decendant of QList, calling erase on the iterator makes the loop crash with SIGSEGV. So check if the file is already in the queue before enqueuing.
Diffstat (limited to 'smdirwatcher.cpp')
-rw-r--r--smdirwatcher.cpp4
1 files changed, 3 insertions, 1 deletions
diff --git a/smdirwatcher.cpp b/smdirwatcher.cpp
index 87d2eff..839b021 100644
--- a/smdirwatcher.cpp
+++ b/smdirwatcher.cpp
@@ -81,7 +81,9 @@ void SmDirWatcher::run(){
goto out;
}
c = qMakePair(name, curEvent);
- mDataQueue->enqueue(c);
+ if(!mDataQueue->contains(c)){
+ mDataQueue->enqueue(c);
+ }
out:
mSemUsed->release();
i += sizeof(inotify_event) + e->len;