Commit 97bf6942 authored by Gong Heng's avatar Gong Heng Committed by Albert Astals Cid
Browse files

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,, 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: default avatarMårten Nordheim <>
(cherry picked from commit bb8fc324)
parent d51b1b13
......@@ -366,7 +366,9 @@ void QInotifyFileSystemWatcherEngine::readFromInotify()
// qDebug("QInotifyFileSystemWatcherEngine::readFromInotify");
int buffSize = 0;
ioctl(inotifyFd, FIONREAD, (char *) &buffSize);
if (ioctl(inotifyFd, FIONREAD, (char *) &buffSize) == -1 || buffSize == 0)
QVarLengthArray<char, 4096> buffer(buffSize);
buffSize = read(inotifyFd,, buffSize);
char *at =;
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment