Raw
1 #ifndef FSM_HEALTH_H
2 #define FSM_HEALTH_H
3
4 /* This needs to be implemented by each backend */
5
6 #ifdef HAVE_FSMONITOR_DAEMON_BACKEND
7
8 struct fsmonitor_daemon_state;
9
10 /*
11 * Initialize platform-specific data for the fsmonitor health thread.
12 * This will be called from the main thread PRIOR to staring the
13 * thread.
14 *
15 * Returns 0 if successful.
16 * Returns -1 otherwise.
17 */
18 int fsm_health__ctor(struct fsmonitor_daemon_state *state);
19
20 /*
21 * Cleanup platform-specific data for the health thread.
22 * This will be called from the main thread AFTER joining the thread.
23 */
24 void fsm_health__dtor(struct fsmonitor_daemon_state *state);
25
26 /*
27 * The main body of the platform-specific event loop to monitor the
28 * health of the daemon process. This will run in the health thread.
29 *
30 * The health thread should call `ipc_server_stop_async()` if it needs
31 * to cause a shutdown. (It should NOT do so if it receives a shutdown
32 * shutdown signal.)
33 *
34 * It should set `state->health_error_code` to -1 if the daemon should exit
35 * with an error.
36 */
37 void fsm_health__loop(struct fsmonitor_daemon_state *state);
38
39 /*
40 * Gently request that the health thread shutdown.
41 * It does not wait for it to stop. The caller should do a JOIN
42 * to wait for it.
43 */
44 void fsm_health__stop_async(struct fsmonitor_daemon_state *state);
45
46 #endif /* HAVE_FSMONITOR_DAEMON_BACKEND */
47 #endif /* FSM_HEALTH_H */