diff options
| author | Francesco Abbate <francesco.bbt@gmail.com> | 2021-12-30 15:45:09 +0100 |
|---|---|---|
| committer | Francesco Abbate <francesco.bbt@gmail.com> | 2021-12-30 15:45:09 +0100 |
| commit | 9578359b2b2f0402b840c86f33a9bba13593c586 (patch) | |
| tree | ecd95001d8031c33db8086304514013fe3c9daed | |
| parent | fd074ff39a69238bb72b37373babd6043e30a5d8 (diff) | |
| download | lite-xl-9578359b2b2f0402b840c86f33a9bba13593c586.tar.gz lite-xl-9578359b2b2f0402b840c86f33a9bba13593c586.zip | |
Remove inotify recursive directory monitoring
We no longer use in Lite XL recursive directory monitoring as
it was a source of problems.
To enforce this at compile time we use the preprocessor to
remove the implementation of recursive monitoring for the Linux
implementation only.
| -rw-r--r-- | lib/dmon/dmon.h | 14 |
1 files changed, 13 insertions, 1 deletions
diff --git a/lib/dmon/dmon.h b/lib/dmon/dmon.h index 2bc9e0c3..f04e27d1 100644 --- a/lib/dmon/dmon.h +++ b/lib/dmon/dmon.h @@ -169,6 +169,8 @@ DMON_API_DECL void dmon_unwatch(dmon_watch_id id); # include <time.h> # include <unistd.h> # include <stdlib.h> +/* Recursive removed for Lite XL when using inotify. */ +# define LITE_XL_DISABLE_INOTIFY_RECURSIVE #elif DMON_OS_MACOS # include <pthread.h> # include <CoreServices/CoreServices.h> @@ -710,6 +712,10 @@ typedef struct dmon__state { static bool _dmon_init; static dmon__state _dmon; +/* Implementation of recursive monitoring was removed on Linux for the Lite XL + * application. It is never used with recent version of Lite XL starting from 2.0.5 + * and recursive monitoring with inotify was always problematic and half-broken. */ +#ifndef LITE_XL_DISABLE_INOTIFY_RECURSIVE _DMON_PRIVATE void dmon__watch_recursive(const char* dirname, int fd, uint32_t mask, bool followlinks, dmon__watch_state* watch) { @@ -764,6 +770,7 @@ _DMON_PRIVATE void dmon__watch_recursive(const char* dirname, int fd, uint32_t m } closedir(dir); } +#endif _DMON_PRIVATE const char* dmon__find_subdir(const dmon__watch_state* watch, int wd) { @@ -777,6 +784,7 @@ _DMON_PRIVATE const char* dmon__find_subdir(const dmon__watch_state* watch, int return NULL; } +#ifndef LITE_XL_DISABLE_INOTIFY_RECURSIVE _DMON_PRIVATE void dmon__gather_recursive(dmon__watch_state* watch, const char* dirname) { struct dirent* entry; @@ -809,6 +817,7 @@ _DMON_PRIVATE void dmon__gather_recursive(dmon__watch_state* watch, const char* } closedir(dir); } +#endif _DMON_PRIVATE void dmon__inotify_process_events(void) { @@ -919,6 +928,7 @@ _DMON_PRIVATE void dmon__inotify_process_events(void) } if (ev->mask & IN_CREATE) { +# ifndef LITE_XL_DISABLE_INOTIFY_RECURSIVE if (ev->mask & IN_ISDIR) { if (watch->watch_flags & DMON_WATCHFLAGS_RECURSIVE) { char watchdir[DMON_MAX_PATH]; @@ -948,6 +958,7 @@ _DMON_PRIVATE void dmon__inotify_process_events(void) ev = &_dmon.events[i]; // gotta refresh the pointer because it may be relocated } } +# endif watch->watch_cb(ev->watch_id, DMON_ACTION_CREATE, watch->rootdir, ev->filepath, NULL, watch->user_data); } else if (ev->mask & IN_MODIFY) { @@ -1158,11 +1169,12 @@ DMON_API_IMPL dmon_watch_id dmon_watch(const char* rootdir, stb_sb_push(watch->wds, wd); // recursive mode: enumarate all child directories and add them to watch +#ifndef LITE_XL_DISABLE_INOTIFY_RECURSIVE if (flags & DMON_WATCHFLAGS_RECURSIVE) { dmon__watch_recursive(watch->rootdir, watch->fd, inotify_mask, (flags & DMON_WATCHFLAGS_FOLLOW_SYMLINKS) ? true : false, watch); } - +#endif pthread_mutex_unlock(&_dmon.mutex); return dmon__make_id(id); |
