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

Function mainloop_add_fd

lib/common/mainloop.c:703–737  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

701}
702
703mainloop_io_t *
704mainloop_add_fd(
705 const char *name, int priority, int fd, void *userdata, struct mainloop_fd_callbacks *callbacks)
706{
707 mainloop_io_t *client = NULL;
708 if(fd > 0) {
709 client = calloc(1, sizeof(mainloop_io_t));
710 client->name = strdup(name);
711 client->userdata = userdata;
712
713 if(callbacks) {
714 client->destroy_fn = callbacks->destroy;
715 client->dispatch_fn_io = callbacks->dispatch;
716 }
717
718 client->channel = g_io_channel_unix_new(fd);
719 client->source = g_io_add_watch_full(
720 client->channel, priority, (G_IO_IN|G_IO_HUP|G_IO_NVAL|G_IO_ERR),
721 mainloop_gio_callback, client, mainloop_gio_destroy);
722
723 /* Now that mainloop now holds a reference to adaptor->channel,
724 * thanks to g_io_add_watch_full(), drop ours from g_io_channel_unix_new().
725 *
726 * This means that adaptor->channel will be free'd by:
727 * g_main_context_dispatch() or g_source_remove()
728 * -> g_source_destroy_internal()
729 * -> g_source_callback_unref()
730 * shortly after mainloop_gio_destroy() completes
731 */
732 g_io_channel_unref(client->channel);
733 crm_trace("Added connection %d for %s[%p].%d %d", client->source, client->name, client, fd, mainloop_gio_refcount(client));
734 }
735
736 return client;
737}
738
739void
740mainloop_del_fd(mainloop_io_t *client)

Callers 14

init_remote_listenerFunction · 0.85
cib_remote_listenFunction · 0.85
ccm_connectFunction · 0.85
cib_tls_signonFunction · 0.85
mainloop_add_ipc_clientFunction · 0.85
init_cman_connectionFunction · 0.85
init_cpg_connectionFunction · 0.85
init_cpg_connectionFunction · 0.85
init_quorum_connectionFunction · 0.85
cluster_connect_cfgFunction · 0.85

Calls 1

mainloop_gio_refcountFunction · 0.85

Tested by

no test coverage detected