pacemaker  1.1.18-7fdfbbe
Scalable High-Availability cluster resource manager
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
mainloop.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2009 Andrew Beekhof <andrew@beekhof.net>
3  *
4  * This program is free software; you can redistribute it and/or
5  * modify it under the terms of the GNU Lesser General Public
6  * License as published by the Free Software Foundation; either
7  * version 2 of the License, or (at your option) any later version.
8  *
9  * This software is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12  * General Public License for more details.
13  *
14  * You should have received a copy of the GNU Lesser General Public
15  * License along with this library; if not, write to the Free Software
16  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
17  */
18 #ifndef CRM_COMMON_MAINLOOP__H
19 # define CRM_COMMON_MAINLOOP__H
20 
27 # include <glib.h>
28 
30  /* don't kill pid group on timeout, only kill the pid */
32 };
33 
34 typedef struct trigger_s crm_trigger_t;
35 typedef struct mainloop_io_s mainloop_io_t;
36 typedef struct mainloop_child_s mainloop_child_t;
37 typedef struct mainloop_timer_s mainloop_timer_t;
38 
39 void mainloop_cleanup(void);
40 
41 crm_trigger_t *mainloop_add_trigger(int priority, int (*dispatch) (gpointer user_data),
42  gpointer userdata);
43 
44 void mainloop_set_trigger(crm_trigger_t * source);
45 
47 
48 gboolean mainloop_destroy_trigger(crm_trigger_t * source);
49 
50 gboolean crm_signal(int sig, void (*dispatch) (int sig));
51 
52 gboolean mainloop_add_signal(int sig, void (*dispatch) (int sig));
53 
54 gboolean mainloop_destroy_signal(int sig);
55 
57 
59 
61 
62 guint mainloop_timer_set_period(mainloop_timer_t *t, guint period_ms);
63 
64 mainloop_timer_t *mainloop_timer_add(const char *name, guint period_ms, bool repeat, GSourceFunc cb, void *userdata);
65 
67 
68 
69 # include <crm/common/ipc.h>
70 # include <qb/qbipcs.h>
71 
73  int (*dispatch) (const char *buffer, ssize_t length, gpointer userdata);
74  void (*destroy) (gpointer);
75 };
76 
77 qb_ipcs_service_t *mainloop_add_ipc_server(const char *name, enum qb_ipc_type type,
78  struct qb_ipcs_service_handlers *callbacks);
79 
80 void mainloop_del_ipc_server(qb_ipcs_service_t * server);
81 
82 mainloop_io_t *mainloop_add_ipc_client(const char *name, int priority, size_t max_size,
83  void *userdata, struct ipc_client_callbacks *callbacks);
84 
86 
88 
90  int (*dispatch) (gpointer userdata);
91  void (*destroy) (gpointer userdata);
92 };
93 
94 mainloop_io_t *mainloop_add_fd(const char *name, int priority, int fd, void *userdata,
95  struct mainloop_fd_callbacks *callbacks);
96 
97 void mainloop_del_fd(mainloop_io_t * client);
98 
99 /*
100  * Create a new tracked process
101  * To track a process group, use -pid
102  */
103 void mainloop_child_add(pid_t pid,
104  int timeout,
105  const char *desc,
106  void *userdata,
107  void (*callback) (mainloop_child_t * p, pid_t pid, int core, int signo, int exitcode));
108 
109 void mainloop_child_add_with_flags(pid_t pid,
110  int timeout,
111  const char *desc,
112  void *userdata,
114  void (*callback) (mainloop_child_t * p, pid_t pid, int core, int signo, int exitcode));
115 
118 const char *mainloop_child_name(mainloop_child_t * child);
119 
120 pid_t mainloop_child_pid(mainloop_child_t * child);
122 gboolean mainloop_child_kill(pid_t pid);
123 
124 # define G_PRIORITY_MEDIUM (G_PRIORITY_HIGH/2)
125 
126 #endif
gboolean mainloop_add_signal(int sig, void(*dispatch)(int sig))
Definition: mainloop.c:327
mainloop_io_t * mainloop_add_fd(const char *name, int priority, int fd, void *userdata, struct mainloop_fd_callbacks *callbacks)
Definition: mainloop.c:810
void mainloop_timer_start(mainloop_timer_t *t)
Definition: mainloop.c:1186
guint mainloop_timer_set_period(mainloop_timer_t *t, guint period_ms)
Definition: mainloop.c:1204
mainloop_child_flags
Definition: mainloop.h:29
void mainloop_timer_del(mainloop_timer_t *t)
Definition: mainloop.c:1242
gboolean mainloop_child_kill(pid_t pid)
Definition: mainloop.c:1042
struct mainloop_timer_s mainloop_timer_t
Definition: mainloop.h:37
struct mainloop_io_s mainloop_io_t
Definition: mainloop.h:35
void mainloop_child_add_with_flags(pid_t pid, int timeout, const char *desc, void *userdata, enum mainloop_child_flags, void(*callback)(mainloop_child_t *p, pid_t pid, int core, int signo, int exitcode))
Definition: mainloop.c:1097
struct mainloop_child_s mainloop_child_t
Definition: mainloop.h:36
void mainloop_set_trigger(crm_trigger_t *source)
Definition: mainloop.c:225
void mainloop_cleanup(void)
Definition: mainloop.c:411
int(* dispatch)(gpointer userdata)
Definition: mainloop.h:90
pid_t mainloop_child_pid(mainloop_child_t *child)
Definition: mainloop.c:870
uint32_t pid
Definition: internal.h:49
gboolean mainloop_destroy_trigger(crm_trigger_t *source)
Definition: mainloop.c:233
void mainloop_timer_stop(mainloop_timer_t *t)
Definition: mainloop.c:1195
struct trigger_s crm_trigger_t
Definition: mainloop.h:34
void(* destroy)(gpointer)
Definition: mainloop.h:74
void * mainloop_child_userdata(mainloop_child_t *child)
Definition: mainloop.c:888
struct crm_ipc_s crm_ipc_t
Definition: ipc.h:61
void(* destroy)(gpointer userdata)
Definition: mainloop.h:91
gboolean crm_signal(int sig, void(*dispatch)(int sig))
Definition: mainloop.c:302
crm_trigger_t * mainloop_add_trigger(int priority, int(*dispatch)(gpointer user_data), gpointer userdata)
Definition: mainloop.c:213
void mainloop_del_ipc_client(mainloop_io_t *client)
Definition: mainloop.c:795
bool mainloop_timer_running(mainloop_timer_t *t)
Definition: mainloop.c:1178
void mainloop_child_add(pid_t pid, int timeout, const char *desc, void *userdata, void(*callback)(mainloop_child_t *p, pid_t pid, int core, int signo, int exitcode))
Definition: mainloop.c:1131
void mainloop_trigger_complete(crm_trigger_t *trig)
Definition: mainloop.c:201
crm_ipc_t * mainloop_get_ipc_client(mainloop_io_t *client)
Definition: mainloop.c:801
void mainloop_clear_child_userdata(mainloop_child_t *child)
Definition: mainloop.c:894
Wrappers for and extensions to libqb IPC.
void mainloop_del_fd(mainloop_io_t *client)
Definition: mainloop.c:854
void mainloop_del_ipc_server(qb_ipcs_service_t *server)
Definition: mainloop.c:619
mainloop_timer_t * mainloop_timer_add(const char *name, guint period_ms, bool repeat, GSourceFunc cb, void *userdata)
Definition: mainloop.c:1221
gboolean mainloop_destroy_signal(int sig)
Definition: mainloop.c:385
mainloop_io_t * mainloop_add_ipc_client(const char *name, int priority, size_t max_size, void *userdata, struct ipc_client_callbacks *callbacks)
Definition: mainloop.c:767
qb_ipcs_service_t * mainloop_add_ipc_server(const char *name, enum qb_ipc_type type, struct qb_ipcs_service_handlers *callbacks)
Definition: mainloop.c:589
const char * mainloop_child_name(mainloop_child_t *child)
Definition: mainloop.c:876
int(* dispatch)(const char *buffer, ssize_t length, gpointer userdata)
Definition: mainloop.h:73
enum crm_ais_msg_types type
Definition: internal.h:51
int mainloop_child_timeout(mainloop_child_t *child)
Definition: mainloop.c:882