fsmonitor--daemon: rename listener thread related variables
Rename platform-specific listener thread related variables and data types as we prepare to add another backend thread type. [] `struct fsmonitor_daemon_backend_data` becomes `struct fsm_listen_data` [] `state->backend_data` becomes `state->listen_data` [] `state->error_code` becomes `state->listen_error_code` Signed-off-by: Jeff Hostetler <jeffhost@microsoft.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Jeff Hostetler committed
May 26, 2022 at 21:47 UTC
207534e423d95861c27444d4cf9760bf16edc6c8
5 files changed
+36
-36
builtin/fsmonitor--daemon.c
+3
-3
@@ -1225,8 +1225,8 @@ cleanup:
1225
1226
if (err)
1227
return err;
1228
- if (state->error_code)
1229
- return state->error_code;
1228
+ if (state->listen_error_code)
1229
+ return state->listen_error_code;
1230
return 0;
1231
}
1232
@@ -1241,7 +1241,7 @@ static int fsmonitor_run_daemon(void)
1241
hashmap_init(&state.cookies, cookies_cmp, NULL, 0);
1242
pthread_mutex_init(&state.main_lock, NULL);
1243
pthread_cond_init(&state.cookies_cond, NULL);
1244
- state.error_code = 0;
1244
+ state.listen_error_code = 0;
1245
state.current_token_data = fsmonitor_new_token_data();
1246
1247
/* Prepare to (recursively) watch the <worktree-root> directory. */
compat/fsmonitor/fsm-listen-darwin.c
+15
-15
@@ -27,7 +27,7 @@
27
#include "fsm-listen.h"
28
#include "fsmonitor--daemon.h"
29
30
-struct fsmonitor_daemon_backend_data
30
+struct fsm_listen_data
31
{
32
CFStringRef cfsr_worktree_path;
33
CFStringRef cfsr_gitdir_path;
@@ -158,7 +158,7 @@ static void fsevent_callback(ConstFSEventStreamRef streamRef,
158
const FSEventStreamEventId event_ids[])
159
{
160
struct fsmonitor_daemon_state *state = ctx;
161
- struct fsmonitor_daemon_backend_data *data = state->backend_data;
161
+ struct fsm_listen_data *data = state->listen_data;
162
char **paths = (char **)event_paths;
163
struct fsmonitor_batch *batch = NULL;
164
struct string_list cookie_list = STRING_LIST_INIT_DUP;
@@ -350,11 +350,11 @@ int fsm_listen__ctor(struct fsmonitor_daemon_state *state)
350
NULL,
351
NULL
352
};
353
- struct fsmonitor_daemon_backend_data *data;
353
+ struct fsm_listen_data *data;
354
const void *dir_array[2];
355
356
CALLOC_ARRAY(data, 1);
357
- state->backend_data = data;
357
+ state->listen_data = data;
358
359
data->cfsr_worktree_path = CFStringCreateWithCString(
360
NULL, state->path_worktree_watch.buf, kCFStringEncodingUTF8);
@@ -386,18 +386,18 @@ int fsm_listen__ctor(struct fsmonitor_daemon_state *state)
386
failed:
387
error(_("Unable to create FSEventStream."));
388
389
- FREE_AND_NULL(state->backend_data);
389
+ FREE_AND_NULL(state->listen_data);
390
return -1;
391
}
392
393
void fsm_listen__dtor(struct fsmonitor_daemon_state *state)
394
{
395
- struct fsmonitor_daemon_backend_data *data;
395
+ struct fsm_listen_data *data;
396
397
- if (!state || !state->backend_data)
397
+ if (!state || !state->listen_data)
398
return;
399
400
- data = state->backend_data;
400
+ data = state->listen_data;
401
402
if (data->stream) {
403
if (data->stream_started)
@@ -407,14 +407,14 @@ void fsm_listen__dtor(struct fsmonitor_daemon_state *state)
407
FSEventStreamRelease(data->stream);
408
}
409
410
- FREE_AND_NULL(state->backend_data);
410
+ FREE_AND_NULL(state->listen_data);
411
}
412
413
void fsm_listen__stop_async(struct fsmonitor_daemon_state *state)
414
{
415
- struct fsmonitor_daemon_backend_data *data;
415
+ struct fsm_listen_data *data;
416
417
- data = state->backend_data;
417
+ data = state->listen_data;
418
data->shutdown_style = SHUTDOWN_EVENT;
419
420
CFRunLoopStop(data->rl);
@@ -422,9 +422,9 @@ void fsm_listen__stop_async(struct fsmonitor_daemon_state *state)
422
423
void fsm_listen__loop(struct fsmonitor_daemon_state *state)
424
{
425
- struct fsmonitor_daemon_backend_data *data;
425
+ struct fsm_listen_data *data;
426
427
- data = state->backend_data;
427
+ data = state->listen_data;
428
429
data->rl = CFRunLoopGetCurrent();
430
@@ -441,7 +441,7 @@ void fsm_listen__loop(struct fsmonitor_daemon_state *state)
441
442
switch (data->shutdown_style) {
443
case FORCE_ERROR_STOP:
444
- state->error_code = -1;
444
+ state->listen_error_code = -1;
445
/* fall thru */
446
case FORCE_SHUTDOWN:
447
ipc_server_stop_async(state->ipc_server_data);
@@ -453,7 +453,7 @@ void fsm_listen__loop(struct fsmonitor_daemon_state *state)
453
return;
454
455
force_error_stop_without_loop:
456
- state->error_code = -1;
456
+ state->listen_error_code = -1;
457
ipc_server_stop_async(state->ipc_server_data);
458
return;
459
}
compat/fsmonitor/fsm-listen-win32.c
+14
-14
@@ -54,7 +54,7 @@ struct one_watch
54
wchar_t dotgit_shortname[16]; /* for 8.3 name */
55
};
56
57
-struct fsmonitor_daemon_backend_data
57
+struct fsm_listen_data
58
{
59
struct one_watch *watch_worktree;
60
struct one_watch *watch_gitdir;
@@ -284,7 +284,7 @@ static enum get_relative_result get_relative_longname(
284
285
void fsm_listen__stop_async(struct fsmonitor_daemon_state *state)
286
{
287
- SetEvent(state->backend_data->hListener[LISTENER_SHUTDOWN]);
287
+ SetEvent(state->listen_data->hListener[LISTENER_SHUTDOWN]);
288
}
289
290
static struct one_watch *create_watch(struct fsmonitor_daemon_state *state,
@@ -359,7 +359,7 @@ static void destroy_watch(struct one_watch *watch)
359
free(watch);
360
}
361
362
-static int start_rdcw_watch(struct fsmonitor_daemon_backend_data *data,
362
+static int start_rdcw_watch(struct fsm_listen_data *data,
363
struct one_watch *watch)
364
{
365
DWORD dwNotifyFilter =
@@ -538,7 +538,7 @@ static int process_1_worktree_event(
538
*/
539
static int process_worktree_events(struct fsmonitor_daemon_state *state)
540
{
541
- struct fsmonitor_daemon_backend_data *data = state->backend_data;
541
+ struct fsm_listen_data *data = state->listen_data;
542
struct one_watch *watch = data->watch_worktree;
543
struct strbuf path = STRBUF_INIT;
544
struct string_list cookie_list = STRING_LIST_INIT_DUP;
@@ -669,7 +669,7 @@ force_shutdown:
669
*/
670
static int process_gitdir_events(struct fsmonitor_daemon_state *state)
671
{
672
- struct fsmonitor_daemon_backend_data *data = state->backend_data;
672
+ struct fsm_listen_data *data = state->listen_data;
673
struct one_watch *watch = data->watch_gitdir;
674
struct strbuf path = STRBUF_INIT;
675
struct string_list cookie_list = STRING_LIST_INIT_DUP;
@@ -727,11 +727,11 @@ skip_this_path:
727
728
void fsm_listen__loop(struct fsmonitor_daemon_state *state)
729
{
730
- struct fsmonitor_daemon_backend_data *data = state->backend_data;
730
+ struct fsm_listen_data *data = state->listen_data;
731
DWORD dwWait;
732
int result;
733
734
- state->error_code = 0;
734
+ state->listen_error_code = 0;
735
736
if (start_rdcw_watch(data, data->watch_worktree) == -1)
737
goto force_error_stop;
@@ -796,7 +796,7 @@ void fsm_listen__loop(struct fsmonitor_daemon_state *state)
796
}
797
798
force_error_stop:
799
- state->error_code = -1;
799
+ state->listen_error_code = -1;
800
801
force_shutdown:
802
/*
@@ -813,7 +813,7 @@ clean_shutdown:
813
814
int fsm_listen__ctor(struct fsmonitor_daemon_state *state)
815
{
816
- struct fsmonitor_daemon_backend_data *data;
816
+ struct fsm_listen_data *data;
817
818
CALLOC_ARRAY(data, 1);
819
@@ -846,7 +846,7 @@ int fsm_listen__ctor(struct fsmonitor_daemon_state *state)
846
data->nr_listener_handles++;
847
}
848
849
- state->backend_data = data;
849
+ state->listen_data = data;
850
return 0;
851
852
failed:
@@ -859,16 +859,16 @@ failed:
859
860
void fsm_listen__dtor(struct fsmonitor_daemon_state *state)
861
{
862
- struct fsmonitor_daemon_backend_data *data;
862
+ struct fsm_listen_data *data;
863
864
- if (!state || !state->backend_data)
864
+ if (!state || !state->listen_data)
865
return;
866
867
- data = state->backend_data;
867
+ data = state->listen_data;
868
869
CloseHandle(data->hEventShutdown);
870
destroy_watch(data->watch_worktree);
871
destroy_watch(data->watch_gitdir);
872
873
- FREE_AND_NULL(state->backend_data);
873
+ FREE_AND_NULL(state->listen_data);
874
}
compat/fsmonitor/fsm-listen.h
+1
-1
@@ -33,7 +33,7 @@ void fsm_listen__dtor(struct fsmonitor_daemon_state *state);
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
36
+ * It should set `state->listen_error_code` to -1 if the daemon should exit
37
* with an error.
38
*/
39
void fsm_listen__loop(struct fsmonitor_daemon_state *state);
fsmonitor--daemon.h
+3
-3
@@ -33,7 +33,7 @@ void fsmonitor_batch__free_list(struct fsmonitor_batch *batch);
33
*/
34
void fsmonitor_batch__add_path(struct fsmonitor_batch *batch, const char *path);
35
36
-struct fsmonitor_daemon_backend_data; /* opaque platform-specific data */
36
+struct fsm_listen_data; /* opaque platform-specific data for listener thread */
37
38
struct fsmonitor_daemon_state {
39
pthread_t listener_thread;
@@ -50,8 +50,8 @@ struct fsmonitor_daemon_state {
50
int cookie_seq;
51
struct hashmap cookies;
52
53
- int error_code;
54
- struct fsmonitor_daemon_backend_data *backend_data;
53
+ int listen_error_code;
54
+ struct fsm_listen_data *listen_data;
55
56
struct ipc_server_data *ipc_server_data;
57
struct strbuf path_ipc;