snsinfu / ftrap

Simple linux utility that wraps command and signals file changes.
Boost Software License 1.0
0 stars 0 forks source link

Polling interval for file creation #4

Open snsinfu opened 5 years ago

snsinfu commented 5 years ago

The v0.2.0 release uses fixed 3-second interval for detecting file creation:

https://github.com/snsinfu/ftrap/blob/v0.2.0/src/ftrap.c#L26

It should work well enough for typical server programs that just reload config file. So this is not a big problem, but shouldn’t the interval be configurable? Is there any better way than periodic polling?

snsinfu commented 5 years ago

At least the timeout argument for poll(2) can be -1 when queue is empty. This way we can eliminate periodic wakeup in most common case (where watched paths exist).

snsinfu commented 5 years ago

The timeout optimization is implemented: 264ed6c30f9a63d6cd4f245cdef67ed3126d33ac