Skip to content

Commit 62c7367

Browse files
jeffhostetlergitster
authored andcommitted
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 <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent abc9dbc commit 62c7367

File tree

6 files changed

+101
-0
lines changed

6 files changed

+101
-0
lines changed

Makefile

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -470,6 +470,11 @@ all::
470470
# directory, and the JSON compilation database 'compile_commands.json' will be
471471
# created at the root of the repository.
472472
#
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+
#
473478
# Define DEVELOPER to enable more compiler warnings. Compiler version
474479
# and family are auto detected, but could be overridden by defining
475480
# COMPILER_FEATURES (see config.mak.dev). You can still set
@@ -1968,6 +1973,11 @@ ifdef NEED_ACCESS_ROOT_HANDLER
19681973
COMPAT_OBJS += compat/access.o
19691974
endif
19701975

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+
19711981
ifeq ($(TCLTK_PATH),)
19721982
NO_TCLTK = NoThanks
19731983
endif
@@ -2887,6 +2897,9 @@ GIT-BUILD-OPTIONS: FORCE
28872897
@echo DC_SHA1=\''$(subst ','\'',$(subst ','\'',$(DC_SHA1)))'\' >>$@+
28882898
@echo SANITIZE_LEAK=\''$(subst ','\'',$(subst ','\'',$(SANITIZE_LEAK)))'\' >>$@+
28892899
@echo X=\'$(X)\' >>$@+
2900+
ifdef FSMONITOR_DAEMON_BACKEND
2901+
@echo FSMONITOR_DAEMON_BACKEND=\''$(subst ','\'',$(subst ','\'',$(FSMONITOR_DAEMON_BACKEND)))'\' >>$@+
2902+
endif
28902903
ifdef TEST_OUTPUT_DIRECTORY
28912904
@echo TEST_OUTPUT_DIRECTORY=\''$(subst ','\'',$(subst ','\'',$(TEST_OUTPUT_DIRECTORY)))'\' >>$@+
28922905
endif

compat/fsmonitor/fsm-listen-win32.c

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -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

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -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

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -435,6 +435,11 @@ ifeq ($(uname_S),Windows)
435435
# so we don't need this:
436436
#
437437
# 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
438443
NO_SVN_TESTS = YesPlease
439444
RUNTIME_PREFIX = YesPlease
440445
HAVE_WPGMPTR = YesWeDo
@@ -619,6 +624,11 @@ ifeq ($(uname_S),MINGW)
619624
NO_STRTOUMAX = YesPlease
620625
NO_MKDTEMP = YesPlease
621626
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
622632
RUNTIME_PREFIX = YesPlease
623633
HAVE_WPGMPTR = YesWeDo
624634
NO_ST_BLOCKS_IN_STRUCT_STAT = YesPlease

contrib/buildsystems/CMakeLists.txt

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -285,6 +285,13 @@ else()
285285
endif()
286286
endif()
287287

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+
288295
set(EXE_EXTENSION ${CMAKE_EXECUTABLE_SUFFIX})
289296

290297
#header checks

repo-settings.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
#include "config.h"
33
#include "repository.h"
44
#include "midx.h"
5+
#include "compat/fsmonitor/fsm-listen.h"
56

67
static void repo_cfg_bool(struct repository *r, const char *key, int *dest,
78
int def)

0 commit comments

Comments
 (0)