compat/fsmonitor/fsm-listen-win32: stub in backend for Windows
Stub in empty filesystem listener backend for fsmonitor--daemon on Windows. Signed-off-by: Jeff Hostetler <jeffhost@microsoft.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Jeff Hostetler committed
Mar 25, 2022 at 18:02 UTC
62c7367133e081973e27b7d53e812103fc7ad6d9
6 files changed
+101
Makefile
+13
@@ -470,6 +470,11 @@ all::
470
# directory, and the JSON compilation database 'compile_commands.json' will be
471
# created at the root of the repository.
472
#
473
+# If your platform supports a built-in fsmonitor backend, set
474
+# FSMONITOR_DAEMON_BACKEND to the "<name>" of the corresponding
475
+# `compat/fsmonitor/fsm-listen-<name>.c` that implements the
476
+# `fsm_listen__*()` routines.
477
+#
478
# Define DEVELOPER to enable more compiler warnings. Compiler version
479
# and family are auto detected, but could be overridden by defining
480
# COMPILER_FEATURES (see config.mak.dev). You can still set
@@ -1968,6 +1973,11 @@ ifdef NEED_ACCESS_ROOT_HANDLER
1973
COMPAT_OBJS += compat/access.o
1974
endif
1975
1976
+ifdef FSMONITOR_DAEMON_BACKEND
1977
+ COMPAT_CFLAGS += -DHAVE_FSMONITOR_DAEMON_BACKEND
1978
+ COMPAT_OBJS += compat/fsmonitor/fsm-listen-$(FSMONITOR_DAEMON_BACKEND).o
1979
+endif
1980
+
1981
ifeq ($(TCLTK_PATH),)
1982
NO_TCLTK = NoThanks
1983
endif
@@ -2887,6 +2897,9 @@ GIT-BUILD-OPTIONS: FORCE
2897
@echo DC_SHA1=\''$(subst ','\'',$(subst ','\'',$(DC_SHA1)))'\' >>$@+
2898
@echo SANITIZE_LEAK=\''$(subst ','\'',$(subst ','\'',$(SANITIZE_LEAK)))'\' >>$@+
2899
@echo X=\'$(X)\' >>$@+
2900
+ifdef FSMONITOR_DAEMON_BACKEND
2901
+ @echo FSMONITOR_DAEMON_BACKEND=\''$(subst ','\'',$(subst ','\'',$(FSMONITOR_DAEMON_BACKEND)))'\' >>$@+
2902
+endif
2903
ifdef TEST_OUTPUT_DIRECTORY
2904
@echo TEST_OUTPUT_DIRECTORY=\''$(subst ','\'',$(subst ','\'',$(TEST_OUTPUT_DIRECTORY)))'\' >>$@+
2905
endif
compat/fsmonitor/fsm-listen-win32.c
new
+21
@@ -0,0 +1,21 @@
1
+#include "cache.h"
2
+#include "config.h"
3
+#include "fsmonitor.h"
4
+#include "fsm-listen.h"
5
+
6
+void fsm_listen__stop_async(struct fsmonitor_daemon_state *state)
7
+{
8
+}
9
+
10
+void fsm_listen__loop(struct fsmonitor_daemon_state *state)
11
+{
12
+}
13
+
14
+int fsm_listen__ctor(struct fsmonitor_daemon_state *state)
15
+{
16
+ return -1;
17
+}
18
+
19
+void fsm_listen__dtor(struct fsmonitor_daemon_state *state)
20
+{
21
+}
compat/fsmonitor/fsm-listen.h
new
+49
@@ -0,0 +1,49 @@
1
+#ifndef FSM_LISTEN_H
2
+#define FSM_LISTEN_H
3
+
4
+/* This needs to be implemented by each backend */
5
+
6
+#ifdef HAVE_FSMONITOR_DAEMON_BACKEND
7
+
8
+struct fsmonitor_daemon_state;
9
+
10
+/*
11
+ * Initialize platform-specific data for the fsmonitor listener thread.
12
+ * This will be called from the main thread PRIOR to staring the
13
+ * fsmonitor_fs_listener thread.
14
+ *
15
+ * Returns 0 if successful.
16
+ * Returns -1 otherwise.
17
+ */
18
+int fsm_listen__ctor(struct fsmonitor_daemon_state *state);
19
+
20
+/*
21
+ * Cleanup platform-specific data for the fsmonitor listener thread.
22
+ * This will be called from the main thread AFTER joining the listener.
23
+ */
24
+void fsm_listen__dtor(struct fsmonitor_daemon_state *state);
25
+
26
+/*
27
+ * The main body of the platform-specific event loop to watch for
28
+ * filesystem events. This will run in the fsmonitor_fs_listen thread.
29
+ *
30
+ * It should call `ipc_server_stop_async()` if the listener thread
31
+ * prematurely terminates (because of a filesystem error or if it
32
+ * detects that the .git directory has been deleted). (It should NOT
33
+ * do so if the listener thread receives a normal shutdown signal from
34
+ * the IPC layer.)
35
+ *
36
+ * It should set `state->error_code` to -1 if the daemon should exit
37
+ * with an error.
38
+ */
39
+void fsm_listen__loop(struct fsmonitor_daemon_state *state);
40
+
41
+/*
42
+ * Gently request that the fsmonitor listener thread shutdown.
43
+ * It does not wait for it to stop. The caller should do a JOIN
44
+ * to wait for it.
45
+ */
46
+void fsm_listen__stop_async(struct fsmonitor_daemon_state *state);
47
+
48
+#endif /* HAVE_FSMONITOR_DAEMON_BACKEND */
49
+#endif /* FSM_LISTEN_H */
config.mak.uname
+10
@@ -435,6 +435,11 @@ ifeq ($(uname_S),Windows)
435
# so we don't need this:
436
#
437
# SNPRINTF_RETURNS_BOGUS = YesPlease
438
+
439
+ # The builtin FSMonitor requires Named Pipes and Threads on Windows.
440
+ # These are always available, so we do not have to conditionally
441
+ # support it.
442
+ FSMONITOR_DAEMON_BACKEND = win32
443
NO_SVN_TESTS = YesPlease
444
RUNTIME_PREFIX = YesPlease
445
HAVE_WPGMPTR = YesWeDo
@@ -619,6 +624,11 @@ ifeq ($(uname_S),MINGW)
624
NO_STRTOUMAX = YesPlease
625
NO_MKDTEMP = YesPlease
626
NO_SVN_TESTS = YesPlease
627
+
628
+ # The builtin FSMonitor requires Named Pipes and Threads on Windows.
629
+ # These are always available, so we do not have to conditionally
630
+ # support it.
631
+ FSMONITOR_DAEMON_BACKEND = win32
632
RUNTIME_PREFIX = YesPlease
633
HAVE_WPGMPTR = YesWeDo
634
NO_ST_BLOCKS_IN_STRUCT_STAT = YesPlease
contrib/buildsystems/CMakeLists.txt
+7
@@ -285,6 +285,13 @@ else()
285
endif()
286
endif()
287
288
+if(SUPPORTS_SIMPLE_IPC)
289
+ if(CMAKE_SYSTEM_NAME STREQUAL "Windows")
290
+ add_compile_definitions(HAVE_FSMONITOR_DAEMON_BACKEND)
291
+ list(APPEND compat_SOURCES compat/fsmonitor/fsm-listen-win32.c)
292
+ endif()
293
+endif()
294
+
295
set(EXE_EXTENSION ${CMAKE_EXECUTABLE_SUFFIX})
296
297
#header checks
repo-settings.c
+1
@@ -2,6 +2,7 @@
2
#include "config.h"
3
#include "repository.h"
4
#include "midx.h"
5
+#include "compat/fsmonitor/fsm-listen.h"
6
7
static void repo_cfg_bool(struct repository *r, const char *key, int *dest,
8
int def)