From dbfc4f7bf395bf20aa21058372d47d17d040f553 Mon Sep 17 00:00:00 2001 From: Arno Date: Tue, 27 Aug 2013 12:52:03 +0200 Subject: 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. --- smdirwatcher.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) 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; -- cgit v1.2.3-70-g09d2