本文整理汇总了C++中sd_bus_unref函数的典型用法代码示例。如果您正苦于以下问题:C++ sd_bus_unref函数的具体用法?C++ sd_bus_unref怎么用?C++ sd_bus_unref使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了sd_bus_unref函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: test_one
static void test_one(
const char *path,
const char *interface,
const char *member,
const char *arg0,
const char *match,
bool good) {
_cleanup_close_ int bus_ref = -1;
_cleanup_free_ char *name = NULL, *bus_name = NULL, *address = NULL;
_cleanup_bus_message_unref_ sd_bus_message *m = NULL;
sd_bus *a, *b;
int r;
assert_se(asprintf(&name, "deine-mutter-%u", (unsigned) getpid()) >= 0);
bus_ref = bus_kernel_create_bus(name, false, &bus_name);
if (bus_ref == -ENOENT)
exit(EXIT_TEST_SKIP);
assert_se(bus_ref >= 0);
address = strappend("kernel:path=", bus_name);
assert_se(address);
r = sd_bus_new(&a);
assert_se(r >= 0);
r = sd_bus_new(&b);
assert_se(r >= 0);
r = sd_bus_set_address(a, address);
assert_se(r >= 0);
r = sd_bus_set_address(b, address);
assert_se(r >= 0);
r = sd_bus_start(a);
assert_se(r >= 0);
r = sd_bus_start(b);
assert_se(r >= 0);
log_debug("match");
r = sd_bus_add_match(b, NULL, match, NULL, NULL);
assert_se(r >= 0);
log_debug("signal");
r = sd_bus_emit_signal(a, path, interface, member, "s", arg0);
assert_se(r >= 0);
r = sd_bus_process(b, &m);
assert_se(r >= 0 && (good == !!m));
sd_bus_unref(a);
sd_bus_unref(b);
}
示例2: manager_free
void manager_free(Manager *m) {
Network *network;
Bridge *bridge;
Link *link;
udev_monitor_unref(m->udev_monitor);
udev_unref(m->udev);
sd_bus_unref(m->bus);
sd_event_source_unref(m->udev_event_source);
sd_event_unref(m->event);
while ((network = m->networks))
network_free(network);
while ((link = hashmap_first(m->links)))
link_free(link);
hashmap_free(m->links);
while ((bridge = hashmap_first(m->bridges)))
bridge_free(bridge);
hashmap_free(m->bridges);
sd_rtnl_unref(m->rtnl);
free(m);
}
示例3: manager_free
void manager_free(Manager *m) {
Network *network;
NetDev *netdev;
Link *link;
if (!m)
return;
udev_monitor_unref(m->udev_monitor);
udev_unref(m->udev);
sd_bus_unref(m->bus);
sd_event_source_unref(m->udev_event_source);
sd_event_source_unref(m->sigterm_event_source);
sd_event_source_unref(m->sigint_event_source);
sd_event_unref(m->event);
while ((network = m->networks))
network_free(network);
while ((link = hashmap_first(m->links)))
link_free(link);
hashmap_free(m->links);
while ((netdev = hashmap_first(m->netdevs)))
netdev_free(netdev);
hashmap_free(m->netdevs);
sd_rtnl_unref(m->rtnl);
free(m);
}
示例4: connect_bus
static int
connect_bus(void)
{
int r;
sd_bus *bus = NULL;
struct source_ctx *s;
r = sd_bus_default_system(&bus);
SOL_INT_CHECK(r, < 0, r);
s = sol_mainloop_source_get_data(_ctx.mainloop_source);
r = sd_bus_attach_event(bus, s->event,
SD_EVENT_PRIORITY_NORMAL);
SOL_INT_CHECK_GOTO(r, < 0, fail);
r = sd_bus_add_match(bus, NULL,
"type='signal',"
"sender='org.freedesktop.DBus.Local',"
"interface='org.freedesktop.DBus.Local',"
"member='Disconnected'",
_match_disconnected, &_ctx);
SOL_INT_CHECK_GOTO(r, < 0, fail);
_ctx.bus = bus;
return 0;
fail:
sd_bus_unref(bus);
return r;
}
示例5: manager_free
static void manager_free(struct manager *m)
{
unsigned int i;
struct link *l;
if (!m)
return;
while ((l = MANAGER_FIRST_LINK(m)))
link_free(l);
manager_dbus_disconnect(m);
shl_htable_clear_uint(&m->links, NULL, NULL);
sd_event_source_unref(m->udev_mon_source);
udev_monitor_unref(m->udev_mon);
udev_unref(m->udev);
for (i = 0; m->sigs[i]; ++i)
sd_event_source_unref(m->sigs[i]);
sd_bus_unref(m->bus);
sd_event_unref(m->event);
free(m->friendly_name);
free(m);
}
示例6: manager_free
void manager_free(Manager *m) {
Machine *machine;
assert(m);
while (m->operations)
operation_free(m->operations);
assert(m->n_operations == 0);
while ((machine = hashmap_first(m->machines)))
machine_free(machine);
hashmap_free(m->machines);
hashmap_free(m->machine_units);
hashmap_free(m->machine_leaders);
hashmap_free_with_destructor(m->image_cache, image_unref);
sd_event_source_unref(m->image_cache_defer_event);
bus_verify_polkit_async_registry_free(m->polkit_registry);
sd_bus_unref(m->bus);
sd_event_unref(m->event);
free(m);
}
示例7: manager_free
void manager_free(Manager *m) {
Machine *machine;
Image *i;
assert(m);
while ((machine = hashmap_first(m->machines)))
machine_free(machine);
hashmap_free(m->machines);
hashmap_free(m->machine_units);
hashmap_free(m->machine_leaders);
while ((i = hashmap_steal_first(m->image_cache)))
image_unref(i);
hashmap_free(m->image_cache);
sd_event_source_unref(m->image_cache_defer_event);
bus_verify_polkit_async_registry_free(m->polkit_registry);
sd_bus_unref(m->bus);
sd_event_unref(m->event);
free(m);
}
示例8: sd_bus_unref
static struct ratbagctl *ratbagctl_free(struct ratbagctl *ctl)
{
if (!ctl)
return NULL;
ctl->bus = sd_bus_unref(ctl->bus);
return mfree(ctl);
}
示例9: assert_se
static void *server(void *p) {
struct context *c = p;
sd_bus *bus = NULL;
sd_id128_t id;
int r;
c->quit = false;
assert_se(sd_id128_randomize(&id) >= 0);
assert_se(sd_bus_new(&bus) >= 0);
assert_se(sd_bus_set_fd(bus, c->fds[0], c->fds[0]) >= 0);
assert_se(sd_bus_set_server(bus, 1, id) >= 0);
assert_se(sd_bus_add_object_vtable(bus, NULL, "/foo", "org.freedesktop.systemd.test", vtable, c) >= 0);
assert_se(sd_bus_add_object_vtable(bus, NULL, "/foo", "org.freedesktop.systemd.test2", vtable, c) >= 0);
assert_se(sd_bus_add_fallback_vtable(bus, NULL, "/value", "org.freedesktop.systemd.ValueTest", vtable2, NULL, UINT_TO_PTR(20)) >= 0);
assert_se(sd_bus_add_node_enumerator(bus, NULL, "/value", enumerator_callback, NULL) >= 0);
assert_se(sd_bus_add_node_enumerator(bus, NULL, "/value/a", enumerator2_callback, NULL) >= 0);
assert_se(sd_bus_add_object_manager(bus, NULL, "/value") >= 0);
assert_se(sd_bus_add_object_manager(bus, NULL, "/value/a") >= 0);
assert_se(sd_bus_start(bus) >= 0);
log_error("Entering event loop on server");
while (!c->quit) {
log_error("Loop!");
r = sd_bus_process(bus, NULL);
if (r < 0) {
log_error_errno(r, "Failed to process requests: %m");
goto fail;
}
if (r == 0) {
r = sd_bus_wait(bus, (uint64_t) -1);
if (r < 0) {
log_error_errno(r, "Failed to wait: %m");
goto fail;
}
continue;
}
}
r = 0;
fail:
if (bus) {
sd_bus_flush(bus);
sd_bus_unref(bus);
}
return INT_TO_PTR(r);
}
示例10: client_chart
static void client_chart(const char *address) {
_cleanup_bus_message_unref_ sd_bus_message *x = NULL;
size_t csize;
sd_bus *b;
int r;
r = sd_bus_new(&b);
assert_se(r >= 0);
r = sd_bus_set_address(b, address);
assert_se(r >= 0);
r = sd_bus_start(b);
assert_se(r >= 0);
assert_se(sd_bus_call_method(b, ":1.1", "/", "benchmark.server", "Ping", NULL, NULL, NULL) >= 0);
printf("SIZE\tCOPY\tMEMFD\n");
for (csize = 1; csize <= MAX_SIZE; csize *= 2) {
usec_t t;
unsigned n_copying, n_memfd;
printf("%zu\t", csize);
b->use_memfd = 0;
t = now(CLOCK_MONOTONIC);
for (n_copying = 0;; n_copying++) {
transaction(b, csize);
if (now(CLOCK_MONOTONIC) >= t + arg_loop_usec)
break;
}
printf("%u\t", (unsigned) ((n_copying * USEC_PER_SEC) / arg_loop_usec));
b->use_memfd = -1;
t = now(CLOCK_MONOTONIC);
for (n_memfd = 0;; n_memfd++) {
transaction(b, csize);
if (now(CLOCK_MONOTONIC) >= t + arg_loop_usec)
break;
}
printf("%u\n", (unsigned) ((n_memfd * USEC_PER_SEC) / arg_loop_usec));
}
b->use_memfd = 1;
assert_se(sd_bus_message_new_method_call(b, ":1.1", "/", "benchmark.server", "Exit", &x) >= 0);
assert_se(sd_bus_message_append(x, "t", csize) >= 0);
assert_se(sd_bus_send(b, x, NULL) >= 0);
sd_bus_unref(b);
}
示例11: run_context_free
static void run_context_free(RunContext *c) {
assert(c);
c->forward = pty_forward_free(c->forward);
c->match = sd_bus_slot_unref(c->match);
c->bus = sd_bus_unref(c->bus);
c->event = sd_event_unref(c->event);
free(c->active_state);
free(c->result);
}
示例12: main
int main(int argc, char *argv[]) {
sd_bus_slot *slot = NULL;
int r;
char *mode = NULL;
/* Connect to system bus */
// r = sd_bus_open_user(&bus);
r = sd_bus_open_system(&bus);
if (r < 0) {
fprintf(stderr, "Failed to connect to system bus: %s\n",
strerror(-r));
goto finish;
}
r = sd_bus_add_match(bus, &slot, FILTER, bus_signal_cb, NULL);
if (r < 0) {
fprintf(stderr, "Failed: sd_bus_add_match: %s : %s\n", strerror(-r), FILTER);
goto finish;
}
r = sd_bus_add_match(bus, &slot, FILTER2, greeting, NULL);
if (r < 0) {
fprintf(stderr, "Failed: %d sd_bus_add_match: %s : %s\n", __LINE__, strerror(-r), FILTER);
goto finish;
}
for (;;) {
/* Process requests */
r = sd_bus_process(bus, NULL);
if (r < 0) {
fprintf(stderr, "Failed to process bus: %s\n", strerror(-r));
goto finish;
}
if (r > 0) {
continue;
}
r = sd_bus_wait(bus, (uint64_t) - 1);
if (r < 0) {
fprintf(stderr, "Failed to wait on bus: %s\n", strerror(-r));
goto finish;
}
}
finish:
sd_bus_slot_unref(slot);
sd_bus_unref(bus);
return r < 0 ? EXIT_FAILURE : EXIT_SUCCESS;
}
示例13: server_done
static void server_done(Server *s) {
assert(s);
while (s->fifos)
fifo_free(s->fifos);
safe_close(s->epoll_fd);
if (s->bus) {
sd_bus_flush(s->bus);
sd_bus_unref(s->bus);
}
}
示例14: grdev_session_free
static Modeset *modeset_free(Modeset *m) {
if (!m)
return NULL;
m->grdev_session = grdev_session_free(m->grdev_session);
m->grdev = grdev_context_unref(m->grdev);
m->sysview = sysview_context_free(m->sysview);
m->exit_src = sd_event_source_unref(m->exit_src);
m->bus = sd_bus_unref(m->bus);
m->event = sd_event_unref(m->event);
free(m->seat);
free(m->session);
free(m);
return NULL;
}
示例15: assert
Manager *manager_free(Manager *m) {
if (!m)
return NULL;
assert(!m->workspace_list);
m->idev = idev_context_unref(m->idev);
m->grdev = grdev_context_unref(m->grdev);
m->sysview = sysview_context_free(m->sysview);
m->uf = unifont_unref(m->uf);
m->sysbus = sd_bus_unref(m->sysbus);
m->event = sd_event_unref(m->event);
free(m);
return NULL;
}