From b405b59dca7c3340ce424313c8e538dacbc2e824 Mon Sep 17 00:00:00 2001 From: "Bradley T. Hughes" Date: Tue, 1 Dec 2009 13:11:51 +0100 Subject: Fix regression in tst_QFileSystemWatcher Dnotify doesn't work on dup'ed file descriptors apparently, so we need to closedir() before using fcntl() to set the watches. Reviewed-by: TrustMe --- src/corelib/io/qfilesystemwatcher_dnotify.cpp | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/src/corelib/io/qfilesystemwatcher_dnotify.cpp b/src/corelib/io/qfilesystemwatcher_dnotify.cpp index 1fab010..c70232c 100644 --- a/src/corelib/io/qfilesystemwatcher_dnotify.cpp +++ b/src/corelib/io/qfilesystemwatcher_dnotify.cpp @@ -272,6 +272,9 @@ QStringList QDnotifyFileSystemWatcherEngine::addPaths(const QStringList &paths, fd = qt_safe_dup(::dirfd(d)); int parentFd = parent ? qt_safe_dup(::dirfd(parent)) : 0; + ::closedir(d); + if(parent) ::closedir(parent); + Q_ASSERT(fd); if(::fcntl(fd, F_SETSIG, SIGIO) || ::fcntl(fd, F_NOTIFY, DN_MODIFY | DN_CREATE | DN_DELETE | @@ -279,10 +282,6 @@ QStringList QDnotifyFileSystemWatcherEngine::addPaths(const QStringList &paths, (parent && ::fcntl(parentFd, F_SETSIG, SIGIO)) || (parent && ::fcntl(parentFd, F_NOTIFY, DN_DELETE | DN_RENAME | DN_MULTISHOT))) { - - ::closedir(d); - if(parent) ::closedir(parent); - continue; // Could not set appropriate flags } @@ -295,9 +294,6 @@ QStringList QDnotifyFileSystemWatcherEngine::addPaths(const QStringList &paths, pathToFD.insert(path, fd); if(parentFd) parentToFD.insert(parentFd, fd); - - ::closedir(d); - if(parent) ::closedir(parent); } Directory &directory = fdToDirectory[fd]; -- cgit v0.12