10 #ifndef CRM_COMMON_INTERNAL__H 11 #define CRM_COMMON_INTERNAL__H 18 #include <libxml/tree.h> 48 #define PCMK__NELEM(a) ((int) (sizeof(a)/sizeof(a[0])) ) 50 #if SUPPORT_CIBSECRETS 156 const char *expected_name, pid_t *
pid);
177 static inline uint64_t
178 pcmk__set_flags_as(
const char *
function,
int line, uint8_t log_level,
179 const char *flag_type,
const char *
target,
180 uint64_t flag_group, uint64_t
flags,
const char *flags_str)
184 if (
result != flag_group) {
186 "%s flags %#.8llx (%s) for %s set by %s:%d",
187 ((flag_type == NULL)?
"Group of" : flag_type),
188 (
unsigned long long)
flags,
189 ((flags_str == NULL)?
"flags" : flags_str),
211 static inline uint64_t
212 pcmk__clear_flags_as(
const char *
function,
int line, uint8_t log_level,
213 const char *flag_type,
const char *
target,
214 uint64_t flag_group, uint64_t
flags,
const char *flags_str)
218 if (
result != flag_group) {
220 "%s flags %#.8llx (%s) for %s cleared by %s:%d",
221 ((flag_type == NULL)?
"Group of" : flag_type),
222 (
unsigned long long)
flags,
223 ((flags_str == NULL)?
"flags" : flags_str),
239 static inline const char *
240 pcmk__flag_text(uint64_t flag_group, uint64_t
flags)
242 return pcmk__btoa(pcmk_all_flags_set(flag_group,
flags));
273 pcmk__assert_alloc_as(
const char *file,
const char *
function, uint32_t line,
274 size_t nmemb,
size_t size)
276 void *ptr = calloc(nmemb,
size);
279 crm_abort(file,
function, line,
"Out of memory", FALSE, TRUE);
297 #define pcmk__assert_alloc(nmemb, size) \ 298 pcmk__assert_alloc_as(__FILE__, __func__, __LINE__, nmemb, size) 313 pcmk__realloc(
void *ptr,
size_t size)
320 new_ptr = realloc(ptr,
size);
321 if (new_ptr == NULL) {
336 pcmk__list_of_1(GList *list)
338 return list && (list->next == NULL);
343 pcmk__list_of_multiple(GList *list)
345 return list && (list->next != NULL);
350 #define PCMK__FAIL_COUNT_PREFIX "fail-count" 351 #define PCMK__LAST_FAILURE_PREFIX "last-failure" 371 pcmk__fail_attr_name(
const char *prefix,
const char *rsc_id,
const char *op,
374 CRM_CHECK(prefix && rsc_id && op,
return NULL);
379 pcmk__failcount_name(
const char *rsc_id,
const char *op, guint interval_ms)
386 pcmk__lastfailure_name(
const char *rsc_id,
const char *op, guint interval_ms)
#define CRM_CHECK(expr, failure_action)
_Noreturn crm_exit_t crm_exit(crm_exit_t rc)
int pcmk__read_pidfile(const char *filename, pid_t *pid)
int pcmk__substitute_secrets(const char *rsc_id, GHashTable *params)
struct mainloop_timer_s mainloop_timer_t
struct mainloop_io_s mainloop_io_t
void pcmk__xe_set_bool_attr(xmlNodePtr node, const char *name, bool value)
bool pcmk__xe_attr_is_true(const xmlNode *node, const char *name)
Wrappers for and extensions to glib mainloop.
#define PCMK__LAST_FAILURE_PREFIX
Wrappers for and extensions to libqb logging.
bool pcmk__procfs_has_pids(void)
int pcmk__effective_rc(int rc)
char * pcmk__format_nvpair(const char *name, const char *value, const char *units)
#define do_crm_log_unlikely(level, fmt, args...)
Log a message that is likely to be filtered out.
void pcmk__sleep_ms(unsigned int ms)
struct crm_ipc_s crm_ipc_t
External (OS/environmental) problem.
unsigned int pcmk__procfs_num_cores(void)
char * crm_strdup_printf(char const *format,...) G_GNUC_PRINTF(1
int pcmk__scan_nvpair(const char *input, char **name, char **value)
int pcmk__xe_get_bool_attr(const xmlNode *node, const char *name, bool *value)
#define PCMK__FAIL_COUNT_PREFIX
int pcmk__pid_active(pid_t pid, const char *daemon)
pid_t pcmk__locate_sbd(void)
int pcmk__add_mainloop_ipc(crm_ipc_t *ipc, int priority, void *userdata, const struct ipc_client_callbacks *callbacks, mainloop_io_t **source)
Connect to IPC and add it as a main loop source.
pid_t pcmk__procfs_pid_of(const char *name)
void pcmk__daemonize(const char *name, const char *pidfile)
int pcmk__lock_pidfile(const char *filename, const char *name)
pcmk__action_result_t result
char * pcmk__our_nodename
Node name of the local node.
int pcmk__procfs_pid2path(pid_t pid, char path[], size_t path_size)
int pcmk__pidfile_matches(const char *filename, pid_t expected_pid, const char *expected_name, pid_t *pid)
void pcmk__xe_add_node(xmlNode *xml, const char *node, int nodeid)
void pcmk__panic(const char *origin)
void crm_abort(const char *file, const char *function, int line, const char *condition, gboolean do_core, gboolean do_fork)
guint pcmk__mainloop_timer_get_period(const mainloop_timer_t *timer)
Get period for mainloop timer.