diff options
| author | Xavier Del Campo Romero <xavi92@disroot.org> | 2025-09-24 11:01:31 +0200 |
|---|---|---|
| committer | Xavier Del Campo Romero <xavi92@disroot.org> | 2025-09-24 12:39:09 +0200 |
| commit | 173528aef50a4b452acdd8ec9aff13f25c3e092c (patch) | |
| tree | f3b79ae0f4eb067b97997b4c91a859157987c3bc /cftw.h | |
| parent | ebb825d3c622f74f0c47a84e1e388b709dd06c7d (diff) | |
| download | slcl-173528aef50a4b452acdd8ec9aff13f25c3e092c.tar.gz | |
Make search non-blocking
Thanks to a new feature in libweb, it is now possible to generate HTTP
responses asynchronously i.e., without blocking other clients if the
response takes a long time to generate.
This now allow users to search for files or directories without blocking
other users, regardless how much time the search operation takes.
This required cftw to deviate from the POSIX-like, blocking interface it
had so far, and has been replaced now with a non-blocking interface, so
that directories are inspected one entry at a time.
Diffstat (limited to 'cftw.h')
| -rw-r--r-- | cftw.h | 15 |
1 files changed, 12 insertions, 3 deletions
@@ -4,9 +4,18 @@ #include <stdbool.h> #include <sys/stat.h> -/* Thread-safe variant of ftw(3) and nftw(3) that allows passing an - * opaque pointer and removes some unneeded parameters. */ -int cftw(const char *dirpath, int (*fn)(const char *fpath, +enum cftw_state +{ + CFTW_OK, + CFTW_AGAIN, + CFTW_FATAL +}; + +/* Thread-safe and non-blocking variant of ftw(3) and nftw(3) that allows + * passing an opaque pointer and removes some unneeded parameters. */ +struct cftw *cftw(const char *dirpath, int (*fn)(const char *fpath, const struct stat *sb, bool *done, void *user), void *user); +enum cftw_state cftw_step(struct cftw *c); +void cftw_free(struct cftw *c); #endif /* CFTW_H */ |
