Git fork

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>

authored by

Jeff Hostetler and committed by
Junio C Hamano
207534e4 802aa318

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