Skip to content

KDirWatch: handle IN_Q_OVERFLOW events

Méven Car requested to merge meven/kcoreaddons:kdirwatch-handle-overflow into master

CCBUG: 387663

This was handled, indirectly with

            if (!path.isEmpty() && isNoisyFile(cpath.data())) {
                continue;
            }

But when this occurs the events queue should be dropped.

From man inotify

       Note that the event queue can overflow.  In this case, events are
       lost.  Robust applications should handle the possibility of lost
       events gracefully.  For example, it may be necessary to rebuild
       part or all of the application cache.  (One simple, but possibly
       expensive, approach is to close the inotify file descriptor,
       empty the cache, create a new inotify file descriptor, and then
       re-create watches and cache entries for the objects to be
       monitored.)

This is mimicked from what baloo does https://invent.kde.org/frameworks/baloo/-/blob/master/src/file/kinotify.cpp#L342 As @bruns suggested !81 (comment 193063)

cc @bruns @dfaure @sitter

I haven’t tested it as conditions to reproduce are hard to reach, but I don’t think ignoring events can cause too much harm. At least we get a warning message.

Merge request reports