Merge branch 'jh/builtin-fsmonitor-part1'

Built-in fsmonitor (part 1).

* jh/builtin-fsmonitor-part1:
  t/helper/simple-ipc: convert test-simple-ipc to use start_bg_command
  run-command: create start_bg_command
  simple-ipc/ipc-win32: add Windows ACL to named pipe
  simple-ipc/ipc-win32: add trace2 debugging
  simple-ipc: move definition of ipc_active_state outside of ifdef
  simple-ipc: preparations for supporting binary messages.
  trace2: add trace2_child_ready() to report on background children
This commit is contained in:
Junio C Hamano
2021-10-13 15:15:57 -07:00
13 changed files with 591 additions and 202 deletions

View File

@ -510,4 +510,61 @@ int run_processes_parallel_tr2(int n, get_next_task_fn, start_failure_fn,
*/
void prepare_other_repo_env(struct strvec *env_array, const char *new_git_dir);
/**
* Possible return values for start_bg_command().
*/
enum start_bg_result {
/* child process is "ready" */
SBGR_READY = 0,
/* child process could not be started */
SBGR_ERROR,
/* callback error when testing for "ready" */
SBGR_CB_ERROR,
/* timeout expired waiting for child to become "ready" */
SBGR_TIMEOUT,
/* child process exited or was signalled before becomming "ready" */
SBGR_DIED,
};
/**
* Callback used by start_bg_command() to ask whether the
* child process is ready or needs more time to become "ready".
*
* The callback will receive the cmd and cb_data arguments given to
* start_bg_command().
*
* Returns 1 is child needs more time (subject to the requested timeout).
* Returns 0 if child is "ready".
* Returns -1 on any error and cause start_bg_command() to also error out.
*/
typedef int(start_bg_wait_cb)(const struct child_process *cmd, void *cb_data);
/**
* Start a command in the background. Wait long enough for the child
* to become "ready" (as defined by the provided callback). Capture
* immediate errors (like failure to start) and any immediate exit
* status (such as a shutdown/signal before the child became "ready")
* and return this like start_command().
*
* We run a custom wait loop using the provided callback to wait for
* the child to start and become "ready". This is limited by the given
* timeout value.
*
* If the child does successfully start and become "ready", we orphan
* it into the background.
*
* The caller must not call finish_command().
*
* The opaque cb_data argument will be forwarded to the callback for
* any instance data that it might require. This may be NULL.
*/
enum start_bg_result start_bg_command(struct child_process *cmd,
start_bg_wait_cb *wait_cb,
void *cb_data,
unsigned int timeout_sec);
#endif