From d6e0306a90597ff17931dba0a11a593c5f1a7221 Mon Sep 17 00:00:00 2001 From: "Bradley T. Hughes" Date: Wed, 11 Jan 2012 12:42:50 +0100 Subject: Avoid races when destroying QFileSystemWatcher MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit On Mac OS X, socket notifiers need to be disabled/destroyed before closing their associated file descriptor, otherwise we cause races inside the CFSocket system. The documentation for CFSocketInvalidate() says that we close the file descriptor after calling this function when the kCFSocketCloseOnInvalidate flag is explicitly cleared (QCocoaEventDispatcher clears this flag). Do the same on the Linux inotify watcher as well, for symmetry. Change-Id: I5592cc4bb5be4b752e48d895a685d3c92826acc7 Reviewed-by: Robin Burchell Reviewed-by: João Abecasis --- src/corelib/io/qfilesystemwatcher_inotify.cpp | 1 + src/corelib/io/qfilesystemwatcher_kqueue.cpp | 1 + 2 files changed, 2 insertions(+) (limited to 'src/corelib/io') diff --git a/src/corelib/io/qfilesystemwatcher_inotify.cpp b/src/corelib/io/qfilesystemwatcher_inotify.cpp index c1314e61c7..80eb6303cc 100644 --- a/src/corelib/io/qfilesystemwatcher_inotify.cpp +++ b/src/corelib/io/qfilesystemwatcher_inotify.cpp @@ -234,6 +234,7 @@ QInotifyFileSystemWatcherEngine::QInotifyFileSystemWatcherEngine(int fd) QInotifyFileSystemWatcherEngine::~QInotifyFileSystemWatcherEngine() { + notifier.setEnabled(false); foreach (int id, pathToID) inotify_rm_watch(inotifyFd, id < 0 ? -id : id); diff --git a/src/corelib/io/qfilesystemwatcher_kqueue.cpp b/src/corelib/io/qfilesystemwatcher_kqueue.cpp index 2f62176cd4..1f16f6a226 100644 --- a/src/corelib/io/qfilesystemwatcher_kqueue.cpp +++ b/src/corelib/io/qfilesystemwatcher_kqueue.cpp @@ -86,6 +86,7 @@ QKqueueFileSystemWatcherEngine::QKqueueFileSystemWatcherEngine(int kqfd) QKqueueFileSystemWatcherEngine::~QKqueueFileSystemWatcherEngine() { + notifier.setEnabled(false); close(kqfd); foreach (int id, pathToID) -- cgit v1.2.3