https://bugs.kde.org/show_bug.cgi?id=387663

--- Comment #26 from Alexander Kernozhitsky <sh200...@mail.ru> ---
Finally, after some hours of debugging and reading the logs I reached the
reason of this bug. It's triggered when:
- KDirWatch uses inotify as a backend
- the watched directory contains a symlink as one of its parent. For example,
/d is a symlink to /media/data, and our current directory in Dolphin is
something like /d/1/2/3
- the directory is added and then removed:
  $ while true ; do mkdir abc ; sleep 1 ; rmdir abc ; sleep 1 ; done

The problem is that inotify_add_watch reuses the file descriptor if the
directory is already watched. When the directory and the another path to it
with a symlink (e. g. /d/1/2/3 and /media/data/1/2/3) are watched, inotify API
still reuses the file descriptor. But KDirWatch intrinsically considers these
path different, so uses different entries for them. The mapping between file
descriptors and names is kept in QHash<int, Entry *> m_inotify_wd_to_entry, so
the previous entry here is overwritten.

Moreover, when one of these path stops being watched, the file descriptor is
freed and the map entry is removed, so the other path doesn't receive events.

I don't know how to fix this in a simple way (maybe use canonical paths inside
KDirWatch?)

Also note that it's the only one scenario in which the file system updates are
not delivered, there may be other ways to break it and the separate reasons why
this happens. Any missing update in KDirWatch can be the reason.

As I stated in the previous message, KDirWatch can use other methods as default
(FAM, inotify, QFSWatch and Stat). FAM seems to affect performance. Stat will
poll the filesystem each 0.5 seconds, which is not the most efficient way. I
don't know anything about QFSWatch and why it's not use as a default. Some
comments in the code suggest that it lacks some functionality.

As I workaround, I set the environment variable:

KDIRWATCH_METHOD=QFSWatch

-- 
You are receiving this mail because:
You are watching all bug changes.

Reply via email to