Skip to content

Commit 9c307e8

Browse files
jeffhostetlergitster
authored andcommitted
fsmonitor: use IPC to query the builtin FSMonitor daemon
Use simple IPC to directly communicate with the new builtin file system monitor daemon when `core.fsmonitor` is set to true. Signed-off-by: Johannes Schindelin <[email protected]> Signed-off-by: Jeff Hostetler <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 1e0ea5c commit 9c307e8

File tree

1 file changed

+36
-2
lines changed

1 file changed

+36
-2
lines changed

fsmonitor.c

Lines changed: 36 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -241,8 +241,41 @@ void refresh_fsmonitor(struct index_state *istate)
241241
trace_printf_key(&trace_fsmonitor, "refresh fsmonitor");
242242

243243
if (fsm_mode == FSMONITOR_MODE_IPC) {
244-
/* TODO */
245-
return;
244+
query_success = !fsmonitor_ipc__send_query(
245+
istate->fsmonitor_last_update ?
246+
istate->fsmonitor_last_update : "builtin:fake",
247+
&query_result);
248+
if (query_success) {
249+
/*
250+
* The response contains a series of nul terminated
251+
* strings. The first is the new token.
252+
*
253+
* Use `char *buf` as an interlude to trick the CI
254+
* static analysis to let us use `strbuf_addstr()`
255+
* here (and only copy the token) rather than
256+
* `strbuf_addbuf()`.
257+
*/
258+
buf = query_result.buf;
259+
strbuf_addstr(&last_update_token, buf);
260+
bol = last_update_token.len + 1;
261+
is_trivial = query_result.buf[bol] == '/';
262+
if (is_trivial)
263+
trace2_data_intmax("fsm_client", NULL,
264+
"query/trivial-response", 1);
265+
} else {
266+
/*
267+
* The builtin daemon is not available on this
268+
* platform -OR- we failed to get a response.
269+
*
270+
* Generate a fake token (rather than a V1
271+
* timestamp) for the index extension. (If
272+
* they switch back to the hook API, we don't
273+
* want ambiguous state.)
274+
*/
275+
strbuf_addstr(&last_update_token, "builtin:fake");
276+
}
277+
278+
goto apply_results;
246279
}
247280

248281
assert(fsm_mode == FSMONITOR_MODE_HOOK);
@@ -315,6 +348,7 @@ void refresh_fsmonitor(struct index_state *istate)
315348
query_success ? "success" : "failure");
316349
}
317350

351+
apply_results:
318352
/*
319353
* The response from FSMonitor (excluding the header token) is
320354
* either:

0 commit comments

Comments
 (0)