about summary refs log tree commit homepage
path: root/lib/PublicInbox/KQNotify.pm
DateCommit message (Collapse)
2023-10-18Revert "kqnotify: drop EV_CLEAR (edge triggering)"
This reverts commit 13a2088c74fdb4fa51cd97cefc00862cc2082330. It's causing errors on an OpenBSD development snapshot while despite being fine on OpenBSD 7.3 (amd64) and other *BSDs I've tested. Reported-by: Štěpán Němec <stepnem@smrk.net> Link: https://public-inbox.org/meta/20231018170111+0200.599564-stepnem@smrk.net/
2023-10-06kqnotify: drop EV_CLEAR (edge triggering)
I'm not entirely certain how it works with the way we use kevent. I do know IO::KQueue has hard-coded kevent retrievals to 1000 events so it's conceivable we'd end up missing wakeups as we don't loop or requeue in callers. So just rely on the *BSD kernel to provided requeue behavior for us by using level-triggering. In any case, this seems to workaround t/dir_idle.t failures on Dragonfly due to a tmpfs bug in all versions up to v6.4.
2023-09-08fake_inotify + kqnotify: rewrite and combine code
KQNotify is now a subclass of FakeInotify since they're both faking a subset of inotify; and both require directory scanning via readdir() to detect new/deleted files. ctime is no longer used with per-file stat to detect new files with kevent. That proved too unreliable either due to low time resolution of the NetBSD/OpenBSD VFS and/or Time::HiRes::stat being constrained by floating point to represent `struct timespec', so instead we fuzz the time a bit if the ctime is recent and merely compare filenames off readdir. This fixes t/fake_inotify.t and t/kqnotify.t failures under NetBSD and also removes workarounds for OpenBSD in t/kqnotify.t. It also allows us to to remove delays in tests by being more aggressive in picking up new/deleted files in watch directories by adjusting the time to scan if the ctime is recent. This ought to may improve real-world reliability on all *BSDs regardless of whether IO::KQueue is installed.
2022-11-28switch inotify/kevent stuff to v5.12
Another tiny step towards an eventual startup time improvements by avoiding strict.pm
2021-05-15dir_idle: support IN_DELETE_SELF|IN_MOVE_SELF, too
We'll treat IN_MOVE_SELF as IN_DELETE_SELF since there doesn't seem to be a reliable way to distinguish them with FakeInotify, nor know the new name with kevent.
2021-05-15dir_idle: detect files which are gone
lei now makes use of this to clean up after unlinked sockets with less delay. This will also be used to maintain mail_sync.sqlite3.
2021-01-01update copyrights for 2021
Using "make update-copyrights" after setting GNULIB_PATH in my config.mak
2020-07-02inboxidle: avoid per-inbox anonymous subs
Anonymous subs cost over 5K each on x86-64. So prefer the less-recommended-but-still-documented way of using Linux::Inotify2::watch to register watchers. This also updates FakeInotify to detect modifications correctly when used on systems with neither IO::KQueue nor Linux::Inotify2.
2020-06-28kqnotify|fake_inotify: detect Maildir write ops
We need to detect link(2) and rename(2) in other apps writing to the Maildir. We'll be removing the Filesys::Notify::Simple from -watch in favor of using IO::KQueue or Linux::Inotify2 directly. Ensure non-inotify emulations can support everything we expect for Maildir writers.
2020-06-25lock: reduce inotify wakeups
We can reduce the amount of platform-specific code by always relying on IN_MODIFY/NOTE_WRITE notifications from lock release. This reduces the number of times our read-only daemons will need to wake up when -watch sees no-op message changes (e.g. replied, seen, recent flag changes).
2020-06-13t/imapd: support FakeInotify and KQNotify
We can fill in some missing pieces from the emulation APIs to enable IMAP IDLE tests on non-Linux platforms.
2020-06-13inboxidle: new class to detect inbox changes
This will be used to implement IMAP IDLE, first. Eventually, it may be used to trigger other things: * incremental internal updates for manifest.js.gz * restart `git cat-file' processes on pack index unlink * IMAP IDLE-like long-polling HTTP endpoint And maybe more things we haven't thought of, yet. It uses Linux::Inotify2 or IO::KQueue depending on what packages are installed and what the kernel supports. It falls back to nanosecond-aware Time::HiRes::stat() (available with Perl 5.10.0+) on systems lacking Linux::Inotify2 and IO::KQueue. In the future, a pure Perl alternative to Linux::Inotify2 may be supplied for users of architectures we already support signalfd and epoll on. v2 changes: - avoid O_TRUNC on lock file - change ctime on Linux systems w/o inotify - fix naming of comments and fields