MCPcopy Create free account
hub / github.com/ClusterLabs/pacemaker / ccm_connect

Function ccm_connect

cib/main.c:297–375  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

295static void *ccm_library = NULL;
296
297gboolean
298ccm_connect(void)
299{
300 gboolean did_fail = TRUE;
301 int num_ccm_fails = 0;
302 int max_ccm_fails = 30;
303 int ret;
304 int cib_ev_fd;
305
306 int (*ccm_api_register) (oc_ev_t ** token) =
307 find_library_function(&ccm_library, CCM_LIBRARY, "oc_ev_register", 1);
308
309 int (*ccm_api_set_callback) (const oc_ev_t * token,
310 oc_ev_class_t class,
311 oc_ev_callback_t * fn,
312 oc_ev_callback_t ** prev_fn) =
313 find_library_function(&ccm_library, CCM_LIBRARY, "oc_ev_set_callback", 1);
314
315 void (*ccm_api_special) (const oc_ev_t *, oc_ev_class_t, int) =
316 find_library_function(&ccm_library, CCM_LIBRARY, "oc_ev_special", 1);
317 int (*ccm_api_activate) (const oc_ev_t * token, int *fd) =
318 find_library_function(&ccm_library, CCM_LIBRARY, "oc_ev_activate", 1);
319 int (*ccm_api_unregister) (oc_ev_t * token) =
320 find_library_function(&ccm_library, CCM_LIBRARY, "oc_ev_unregister", 1);
321
322 static struct mainloop_fd_callbacks ccm_fd_callbacks =
323 {
324 .dispatch = cib_ccm_dispatch,
325 .destroy = ccm_connection_destroy,
326 };
327
328 while (did_fail) {
329 did_fail = FALSE;
330 crm_info("Registering with CCM...");
331 ret = (*ccm_api_register) (&cib_ev_token);
332 if (ret != 0) {
333 did_fail = TRUE;
334 }
335
336 if (did_fail == FALSE) {
337 crm_trace("Setting up CCM callbacks");
338 ret = (*ccm_api_set_callback) (cib_ev_token, OC_EV_MEMB_CLASS,
339 cib_ccm_msg_callback, NULL);
340 if (ret != 0) {
341 crm_warn("CCM callback not set");
342 did_fail = TRUE;
343 }
344 }
345 if (did_fail == FALSE) {
346 (*ccm_api_special) (cib_ev_token, OC_EV_MEMB_CLASS, 0);
347
348 crm_trace("Activating CCM token");
349 ret = (*ccm_api_activate) (cib_ev_token, &cib_ev_fd);
350 if (ret != 0) {
351 crm_warn("CCM Activation failed");
352 did_fail = TRUE;
353 }
354 }

Callers 2

ccm_connection_destroyFunction · 0.85
cib_initFunction · 0.85

Calls 2

find_library_functionFunction · 0.85
mainloop_add_fdFunction · 0.85

Tested by

no test coverage detected