• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

C++ sd_bus_unref函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C++中sd_bus_unref函数的典型用法代码示例。如果您正苦于以下问题:C++ sd_bus_unref函数的具体用法?C++ sd_bus_unref怎么用?C++ sd_bus_unref使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了sd_bus_unref函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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);
}
开发者ID:Mathnerd314,项目名称:systemd,代码行数:57,代码来源:test-bus-kernel-bloom.c


示例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);
}
开发者ID:jaanek,项目名称:systemd,代码行数:26,代码来源:networkd-manager.c


示例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);
}
开发者ID:wkennington,项目名称:systemd,代码行数:31,代码来源:networkd-manager.c


示例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;
}
开发者ID:cmarcelo,项目名称:soletta,代码行数:32,代码来源:sol-bus.c


示例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);
}
开发者ID:Al3n,项目名称:miraclecast,代码行数:28,代码来源:wifid.c


示例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);
}
开发者ID:atriwidada,项目名称:systemd,代码行数:28,代码来源:machined.c


示例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);
}
开发者ID:arthur-c,项目名称:systemd,代码行数:27,代码来源:machined.c


示例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);
}
开发者ID:whot,项目名称:ratbagd_,代码行数:9,代码来源:ratbagctl.c


示例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);
}
开发者ID:rhvgoyal,项目名称:systemd,代码行数:56,代码来源:test-bus-objects.c


示例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);
}
开发者ID:prodigeni,项目名称:systemd,代码行数:55,代码来源:test-bus-kernel-benchmark.c


示例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);
}
开发者ID:pszewczyk,项目名称:systemd,代码行数:11,代码来源:run.c


示例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;
}
开发者ID:causten,项目名称:samples,代码行数:53,代码来源:ipmiSDbus.c


示例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);
        }
}
开发者ID:GuillaumeSeren,项目名称:systemd,代码行数:13,代码来源:initctl.c


示例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;
}
开发者ID:DStape,项目名称:systemd,代码行数:16,代码来源:modeset.c


示例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;
}
开发者ID:275288698,项目名称:systemd-ubuntu-with-dbus,代码行数:16,代码来源:consoled-manager.c


示例16: idev_session_free

static Evcat *evcat_free(Evcat *e) {
        if (!e)
                return NULL;

        e->idev_session = idev_session_free(e->idev_session);
        e->idev = idev_context_unref(e->idev);
        e->sysview = sysview_context_free(e->sysview);
        e->bus = sd_bus_unref(e->bus);
        e->event = sd_event_unref(e->event);
        free(e->seat);
        free(e->session);
        free(e);

        tcflush(0, TCIOFLUSH);

        return NULL;
}
开发者ID:275288698,项目名称:systemd-ubuntu-with-dbus,代码行数:17,代码来源:evcat.c


示例17: manager_free

void manager_free(Manager *m) {
        Machine *machine;

        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);

        sd_bus_unref(m->bus);
        sd_event_unref(m->event);

        free(m);
}
开发者ID:jrch2k10,项目名称:systemd-hicd,代码行数:17,代码来源:machined.c


示例18: multipath_main_loop

/*
 * This is the main loop of the d-bus service.  It won't exit until
 * quit_dbus_main_loop() is called.
 *
 * It is should be invoked as the startup function of a thread or the caller
 * should not expect it to return.
 */
void * multipath_main_loop(void * ap) {
	sd_bus_slot *slot = NULL;
	sd_bus *bus = NULL;
	int r;

	/* Connect to the user bus this time */
	r = sd_bus_open_user(&bus);
	if (r < 0) {
		fprintf(stderr, "Failed to connect to system bus: %s\n", strerror(-r));
		goto finish;
	}


	sync_maps(bus, slot);

	/* Take a well-known service name so that clients can find us */
	r = sd_bus_request_name(bus, MULTIPATH_BASE_INTERFACE, 0);

	if (r < 0) {
		fprintf(stderr, "Failed to acquire service name: %s\n", strerror(-r));
		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) /* we processed a request, try to process another one, right-away */
			continue;

		/* Wait for the next request to process */
		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 NULL;
}
开发者ID:trgill,项目名称:plugind,代码行数:53,代码来源:multipath_dbus.c


示例19: sd_bus_track_unref

_public_ sd_bus_track* sd_bus_track_unref(sd_bus_track *track) {
        if (!track)
                return NULL;

        assert(track->n_ref > 0);

        if (track->n_ref > 1) {
                track->n_ref--;
                return NULL;
        }

        if (track->in_list)
                LIST_REMOVE(tracks, track->bus->tracks, track);

        bus_track_remove_from_queue(track);
        hashmap_free_with_destructor(track->names, track_item_free);
        sd_bus_unref(track->bus);
        return mfree(track);
}
开发者ID:Werkov,项目名称:systemd,代码行数:19,代码来源:bus-track.c


示例20: dispd_dbus_free

void dispd_dbus_free(struct dispd_dbus *dispd_dbus)
{
	if(!dispd_dbus) {
		return;
	}

	if(dispd_dbus->exposed) {
		sd_bus_release_name(dispd_dbus->bus, "org.freedesktop.miracle.wfd");
	}

	if(dispd_dbus->bus) {
		sd_bus_unref(dispd_dbus->bus);
	}

	if(dispd_dbus->loop) {
		sd_event_unref(dispd_dbus->loop);
	}

	free(dispd_dbus);
}
开发者ID:derekdai,项目名称:miraclecast,代码行数:20,代码来源:dispd-dbus.c



注:本文中的sd_bus_unref函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C++ sd_debug函数代码示例发布时间:2022-05-30
下一篇:
C++ sd_bus_reply_method_return函数代码示例发布时间:2022-05-30
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap