Avoid races when destroying QFileSystemWatcher
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 <robin+qt@viroteck.net> Reviewed-by: João Abecasis <joao.abecasis@nokia.com>
This commit is contained in:
parent
dd22fe636b
commit
d6e0306a90
@ -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);
|
||||
|
||||
|
@ -86,6 +86,7 @@ QKqueueFileSystemWatcherEngine::QKqueueFileSystemWatcherEngine(int kqfd)
|
||||
|
||||
QKqueueFileSystemWatcherEngine::~QKqueueFileSystemWatcherEngine()
|
||||
{
|
||||
notifier.setEnabled(false);
|
||||
close(kqfd);
|
||||
|
||||
foreach (int id, pathToID)
|
||||
|
Loading…
Reference in New Issue
Block a user