diff options
author | Gong Heng <gongheng@uniontech.com> | 2021-03-18 16:53:11 +0800 |
---|---|---|
committer | Mårten Nordheim <marten.nordheim@qt.io> | 2021-04-30 09:37:03 +0000 |
commit | bb8fc324d16278c27a211093fb47bafcc4fe7874 (patch) | |
tree | 68032156772b6b7e8cf830ae5ab469549f11ed66 /src/corelib | |
parent | f5e94444601f85f3cbbebcc3dd9b76d01e60aae3 (diff) |
fix: Optimize the performance of the inotify file system monitoring program。
When the ioctl() functions is executed correctly, the value of buffSize may be 0.
In this situation, there is no need to execute the following code.
This modification can solve two benefits:
1. The readFromInotify function runs frequently, and this modification can improve the
efficiency of the program.
2. When the buffSize is equal to 0, "read(inotifyFd, buffer.data(), buffSize)" function will
be stuck.(I have encountered this kind of problem)
Pick-to: 5.15 6.0 6.1
Change-Id: I9f85491ec91e336b4a1bec5c99b911835c5c06a5
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
Diffstat (limited to 'src/corelib')
-rw-r--r-- | src/corelib/io/qfilesystemwatcher_inotify.cpp | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/src/corelib/io/qfilesystemwatcher_inotify.cpp b/src/corelib/io/qfilesystemwatcher_inotify.cpp index 68e5ab7fa4..27e0b13b0b 100644 --- a/src/corelib/io/qfilesystemwatcher_inotify.cpp +++ b/src/corelib/io/qfilesystemwatcher_inotify.cpp @@ -366,7 +366,7 @@ void QInotifyFileSystemWatcherEngine::readFromInotify() // qDebug("QInotifyFileSystemWatcherEngine::readFromInotify"); int buffSize = 0; - if (ioctl(inotifyFd, FIONREAD, (char *) &buffSize) == -1) + if (ioctl(inotifyFd, FIONREAD, (char *) &buffSize) == -1 || buffSize == 0) return; QVarLengthArray<char, 4096> buffer(buffSize); |