зеркало из https://github.com/microsoft/git.git
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>
This commit is contained in:
Родитель
802aa31840
Коммит
207534e423
|
@ -1225,8 +1225,8 @@ cleanup:
|
|||
|
||||
if (err)
|
||||
return err;
|
||||
if (state->error_code)
|
||||
return state->error_code;
|
||||
if (state->listen_error_code)
|
||||
return state->listen_error_code;
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -1241,7 +1241,7 @@ static int fsmonitor_run_daemon(void)
|
|||
hashmap_init(&state.cookies, cookies_cmp, NULL, 0);
|
||||
pthread_mutex_init(&state.main_lock, NULL);
|
||||
pthread_cond_init(&state.cookies_cond, NULL);
|
||||
state.error_code = 0;
|
||||
state.listen_error_code = 0;
|
||||
state.current_token_data = fsmonitor_new_token_data();
|
||||
|
||||
/* Prepare to (recursively) watch the <worktree-root> directory. */
|
||||
|
|
|
@ -27,7 +27,7 @@
|
|||
#include "fsm-listen.h"
|
||||
#include "fsmonitor--daemon.h"
|
||||
|
||||
struct fsmonitor_daemon_backend_data
|
||||
struct fsm_listen_data
|
||||
{
|
||||
CFStringRef cfsr_worktree_path;
|
||||
CFStringRef cfsr_gitdir_path;
|
||||
|
@ -158,7 +158,7 @@ static void fsevent_callback(ConstFSEventStreamRef streamRef,
|
|||
const FSEventStreamEventId event_ids[])
|
||||
{
|
||||
struct fsmonitor_daemon_state *state = ctx;
|
||||
struct fsmonitor_daemon_backend_data *data = state->backend_data;
|
||||
struct fsm_listen_data *data = state->listen_data;
|
||||
char **paths = (char **)event_paths;
|
||||
struct fsmonitor_batch *batch = NULL;
|
||||
struct string_list cookie_list = STRING_LIST_INIT_DUP;
|
||||
|
@ -350,11 +350,11 @@ int fsm_listen__ctor(struct fsmonitor_daemon_state *state)
|
|||
NULL,
|
||||
NULL
|
||||
};
|
||||
struct fsmonitor_daemon_backend_data *data;
|
||||
struct fsm_listen_data *data;
|
||||
const void *dir_array[2];
|
||||
|
||||
CALLOC_ARRAY(data, 1);
|
||||
state->backend_data = data;
|
||||
state->listen_data = data;
|
||||
|
||||
data->cfsr_worktree_path = CFStringCreateWithCString(
|
||||
NULL, state->path_worktree_watch.buf, kCFStringEncodingUTF8);
|
||||
|
@ -386,18 +386,18 @@ int fsm_listen__ctor(struct fsmonitor_daemon_state *state)
|
|||
failed:
|
||||
error(_("Unable to create FSEventStream."));
|
||||
|
||||
FREE_AND_NULL(state->backend_data);
|
||||
FREE_AND_NULL(state->listen_data);
|
||||
return -1;
|
||||
}
|
||||
|
||||
void fsm_listen__dtor(struct fsmonitor_daemon_state *state)
|
||||
{
|
||||
struct fsmonitor_daemon_backend_data *data;
|
||||
struct fsm_listen_data *data;
|
||||
|
||||
if (!state || !state->backend_data)
|
||||
if (!state || !state->listen_data)
|
||||
return;
|
||||
|
||||
data = state->backend_data;
|
||||
data = state->listen_data;
|
||||
|
||||
if (data->stream) {
|
||||
if (data->stream_started)
|
||||
|
@ -407,14 +407,14 @@ void fsm_listen__dtor(struct fsmonitor_daemon_state *state)
|
|||
FSEventStreamRelease(data->stream);
|
||||
}
|
||||
|
||||
FREE_AND_NULL(state->backend_data);
|
||||
FREE_AND_NULL(state->listen_data);
|
||||
}
|
||||
|
||||
void fsm_listen__stop_async(struct fsmonitor_daemon_state *state)
|
||||
{
|
||||
struct fsmonitor_daemon_backend_data *data;
|
||||
struct fsm_listen_data *data;
|
||||
|
||||
data = state->backend_data;
|
||||
data = state->listen_data;
|
||||
data->shutdown_style = SHUTDOWN_EVENT;
|
||||
|
||||
CFRunLoopStop(data->rl);
|
||||
|
@ -422,9 +422,9 @@ void fsm_listen__stop_async(struct fsmonitor_daemon_state *state)
|
|||
|
||||
void fsm_listen__loop(struct fsmonitor_daemon_state *state)
|
||||
{
|
||||
struct fsmonitor_daemon_backend_data *data;
|
||||
struct fsm_listen_data *data;
|
||||
|
||||
data = state->backend_data;
|
||||
data = state->listen_data;
|
||||
|
||||
data->rl = CFRunLoopGetCurrent();
|
||||
|
||||
|
@ -441,7 +441,7 @@ void fsm_listen__loop(struct fsmonitor_daemon_state *state)
|
|||
|
||||
switch (data->shutdown_style) {
|
||||
case FORCE_ERROR_STOP:
|
||||
state->error_code = -1;
|
||||
state->listen_error_code = -1;
|
||||
/* fall thru */
|
||||
case FORCE_SHUTDOWN:
|
||||
ipc_server_stop_async(state->ipc_server_data);
|
||||
|
@ -453,7 +453,7 @@ void fsm_listen__loop(struct fsmonitor_daemon_state *state)
|
|||
return;
|
||||
|
||||
force_error_stop_without_loop:
|
||||
state->error_code = -1;
|
||||
state->listen_error_code = -1;
|
||||
ipc_server_stop_async(state->ipc_server_data);
|
||||
return;
|
||||
}
|
||||
|
|
|
@ -54,7 +54,7 @@ struct one_watch
|
|||
wchar_t dotgit_shortname[16]; /* for 8.3 name */
|
||||
};
|
||||
|
||||
struct fsmonitor_daemon_backend_data
|
||||
struct fsm_listen_data
|
||||
{
|
||||
struct one_watch *watch_worktree;
|
||||
struct one_watch *watch_gitdir;
|
||||
|
@ -284,7 +284,7 @@ static enum get_relative_result get_relative_longname(
|
|||
|
||||
void fsm_listen__stop_async(struct fsmonitor_daemon_state *state)
|
||||
{
|
||||
SetEvent(state->backend_data->hListener[LISTENER_SHUTDOWN]);
|
||||
SetEvent(state->listen_data->hListener[LISTENER_SHUTDOWN]);
|
||||
}
|
||||
|
||||
static struct one_watch *create_watch(struct fsmonitor_daemon_state *state,
|
||||
|
@ -359,7 +359,7 @@ static void destroy_watch(struct one_watch *watch)
|
|||
free(watch);
|
||||
}
|
||||
|
||||
static int start_rdcw_watch(struct fsmonitor_daemon_backend_data *data,
|
||||
static int start_rdcw_watch(struct fsm_listen_data *data,
|
||||
struct one_watch *watch)
|
||||
{
|
||||
DWORD dwNotifyFilter =
|
||||
|
@ -538,7 +538,7 @@ static int process_1_worktree_event(
|
|||
*/
|
||||
static int process_worktree_events(struct fsmonitor_daemon_state *state)
|
||||
{
|
||||
struct fsmonitor_daemon_backend_data *data = state->backend_data;
|
||||
struct fsm_listen_data *data = state->listen_data;
|
||||
struct one_watch *watch = data->watch_worktree;
|
||||
struct strbuf path = STRBUF_INIT;
|
||||
struct string_list cookie_list = STRING_LIST_INIT_DUP;
|
||||
|
@ -669,7 +669,7 @@ force_shutdown:
|
|||
*/
|
||||
static int process_gitdir_events(struct fsmonitor_daemon_state *state)
|
||||
{
|
||||
struct fsmonitor_daemon_backend_data *data = state->backend_data;
|
||||
struct fsm_listen_data *data = state->listen_data;
|
||||
struct one_watch *watch = data->watch_gitdir;
|
||||
struct strbuf path = STRBUF_INIT;
|
||||
struct string_list cookie_list = STRING_LIST_INIT_DUP;
|
||||
|
@ -727,11 +727,11 @@ skip_this_path:
|
|||
|
||||
void fsm_listen__loop(struct fsmonitor_daemon_state *state)
|
||||
{
|
||||
struct fsmonitor_daemon_backend_data *data = state->backend_data;
|
||||
struct fsm_listen_data *data = state->listen_data;
|
||||
DWORD dwWait;
|
||||
int result;
|
||||
|
||||
state->error_code = 0;
|
||||
state->listen_error_code = 0;
|
||||
|
||||
if (start_rdcw_watch(data, data->watch_worktree) == -1)
|
||||
goto force_error_stop;
|
||||
|
@ -796,7 +796,7 @@ void fsm_listen__loop(struct fsmonitor_daemon_state *state)
|
|||
}
|
||||
|
||||
force_error_stop:
|
||||
state->error_code = -1;
|
||||
state->listen_error_code = -1;
|
||||
|
||||
force_shutdown:
|
||||
/*
|
||||
|
@ -813,7 +813,7 @@ clean_shutdown:
|
|||
|
||||
int fsm_listen__ctor(struct fsmonitor_daemon_state *state)
|
||||
{
|
||||
struct fsmonitor_daemon_backend_data *data;
|
||||
struct fsm_listen_data *data;
|
||||
|
||||
CALLOC_ARRAY(data, 1);
|
||||
|
||||
|
@ -846,7 +846,7 @@ int fsm_listen__ctor(struct fsmonitor_daemon_state *state)
|
|||
data->nr_listener_handles++;
|
||||
}
|
||||
|
||||
state->backend_data = data;
|
||||
state->listen_data = data;
|
||||
return 0;
|
||||
|
||||
failed:
|
||||
|
@ -859,16 +859,16 @@ failed:
|
|||
|
||||
void fsm_listen__dtor(struct fsmonitor_daemon_state *state)
|
||||
{
|
||||
struct fsmonitor_daemon_backend_data *data;
|
||||
struct fsm_listen_data *data;
|
||||
|
||||
if (!state || !state->backend_data)
|
||||
if (!state || !state->listen_data)
|
||||
return;
|
||||
|
||||
data = state->backend_data;
|
||||
data = state->listen_data;
|
||||
|
||||
CloseHandle(data->hEventShutdown);
|
||||
destroy_watch(data->watch_worktree);
|
||||
destroy_watch(data->watch_gitdir);
|
||||
|
||||
FREE_AND_NULL(state->backend_data);
|
||||
FREE_AND_NULL(state->listen_data);
|
||||
}
|
||||
|
|
|
@ -33,7 +33,7 @@ void fsm_listen__dtor(struct fsmonitor_daemon_state *state);
|
|||
* do so if the listener thread receives a normal shutdown signal from
|
||||
* the IPC layer.)
|
||||
*
|
||||
* It should set `state->error_code` to -1 if the daemon should exit
|
||||
* It should set `state->listen_error_code` to -1 if the daemon should exit
|
||||
* with an error.
|
||||
*/
|
||||
void fsm_listen__loop(struct fsmonitor_daemon_state *state);
|
||||
|
|
|
@ -33,7 +33,7 @@ void fsmonitor_batch__free_list(struct fsmonitor_batch *batch);
|
|||
*/
|
||||
void fsmonitor_batch__add_path(struct fsmonitor_batch *batch, const char *path);
|
||||
|
||||
struct fsmonitor_daemon_backend_data; /* opaque platform-specific data */
|
||||
struct fsm_listen_data; /* opaque platform-specific data for listener thread */
|
||||
|
||||
struct fsmonitor_daemon_state {
|
||||
pthread_t listener_thread;
|
||||
|
@ -50,8 +50,8 @@ struct fsmonitor_daemon_state {
|
|||
int cookie_seq;
|
||||
struct hashmap cookies;
|
||||
|
||||
int error_code;
|
||||
struct fsmonitor_daemon_backend_data *backend_data;
|
||||
int listen_error_code;
|
||||
struct fsm_listen_data *listen_data;
|
||||
|
||||
struct ipc_server_data *ipc_server_data;
|
||||
struct strbuf path_ipc;
|
||||
|
|
Загрузка…
Ссылка в новой задаче