diff options
author | Arno <am@disconnect.de> | 2013-08-27 12:52:03 +0200 |
---|---|---|
committer | Arno <am@disconnect.de> | 2013-08-27 12:52:03 +0200 |
commit | dbfc4f7bf395bf20aa21058372d47d17d040f553 (patch) | |
tree | 6ee4b9c182874cbf5e9886ee387f4de22102468d | |
parent | 7a87f1a85527927499325cb9b2a0b9dce8105935 (diff) | |
download | SheMov-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.
-rw-r--r-- | smdirwatcher.cpp | 4 |
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; |