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

C++ BUSNAME函数代码示例

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

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



在下文中一共展示了BUSNAME函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。

示例1: busname_serialize

static int busname_serialize(Unit *u, FILE *f, FDSet *fds) {
        BusName *n = BUSNAME(u);

        assert(n);
        assert(f);
        assert(fds);

        unit_serialize_item(u, f, "state", busname_state_to_string(n->state));
        unit_serialize_item(u, f, "result", busname_result_to_string(n->result));

        if (n->control_pid > 0)
                unit_serialize_item_format(u, f, "control-pid", PID_FMT, n->control_pid);

        if (n->starter_fd >= 0) {
                int copy;

                copy = fdset_put_dup(fds, n->starter_fd);
                if (copy < 0)
                        return copy;

                unit_serialize_item_format(u, f, "starter-fd", "%i", copy);
        }

        return 0;
}
开发者ID:freedesktop-unofficial-mirror,项目名称:systemd__systemd,代码行数:25,代码来源:busname.c


示例2: busname_start

static int busname_start(Unit *u) {
        BusName *n = BUSNAME(u);

        assert(n);

        /* We cannot fulfill this request right now, try again later
         * please! */
        if (IN_SET(n->state, BUSNAME_SIGTERM, BUSNAME_SIGKILL))
                return -EAGAIN;

        /* Already on it! */
        if (n->state == BUSNAME_MAKING)
                return 0;

        if (n->activating && UNIT_ISSET(n->service)) {
                Service *service;

                service = SERVICE(UNIT_DEREF(n->service));

                if (UNIT(service)->load_state != UNIT_LOADED) {
                        log_unit_error(u->id, "Bus service %s not loaded, refusing.", UNIT(service)->id);
                        return -ENOENT;
                }
        }

        assert(IN_SET(n->state, BUSNAME_DEAD, BUSNAME_FAILED));

        n->result = BUSNAME_SUCCESS;
        busname_enter_making(n);

        return 1;
}
开发者ID:freedesktop-unofficial-mirror,项目名称:systemd__systemd,代码行数:32,代码来源:busname.c


示例3: busname_dispatch_timer

static int busname_dispatch_timer(sd_event_source *source, usec_t usec, void *userdata) {
        BusName *n = BUSNAME(userdata);

        assert(n);
        assert(n->timer_event_source == source);

        switch (n->state) {

        case BUSNAME_MAKING:
                log_unit_warning(UNIT(n)->id, "%s making timed out. Terminating.", UNIT(n)->id);
                busname_enter_signal(n, BUSNAME_SIGTERM, BUSNAME_FAILURE_TIMEOUT);
                break;

        case BUSNAME_SIGTERM:
                log_unit_warning(UNIT(n)->id, "%s stopping timed out. Killing.", UNIT(n)->id);
                busname_enter_signal(n, BUSNAME_SIGKILL, BUSNAME_FAILURE_TIMEOUT);
                break;

        case BUSNAME_SIGKILL:
                log_unit_warning(UNIT(n)->id, "%s still around after SIGKILL. Ignoring.", UNIT(n)->id);
                busname_enter_dead(n, BUSNAME_FAILURE_TIMEOUT);
                break;

        default:
                assert_not_reached("Timeout at wrong time.");
        }

        return 0;
}
开发者ID:freedesktop-unofficial-mirror,项目名称:systemd__systemd,代码行数:29,代码来源:busname.c


示例4: busname_trigger_notify

static void busname_trigger_notify(Unit *u, Unit *other) {
        BusName *n = BUSNAME(u);

        assert(n);
        assert(other);

        if (!IN_SET(n->state, BUSNAME_RUNNING, BUSNAME_LISTENING))
                return;

        if (other->start_limit_hit) {
                busname_enter_dead(n, BUSNAME_FAILURE_SERVICE_START_LIMIT_HIT);
                return;
        }

        if (other->load_state != UNIT_LOADED || other->type != UNIT_SERVICE)
                return;

        if (IN_SET(SERVICE(other)->state,
                   SERVICE_DEAD, SERVICE_FAILED,
                   SERVICE_FINAL_SIGTERM, SERVICE_FINAL_SIGKILL,
                   SERVICE_AUTO_RESTART))
                busname_enter_listening(n);

        if (SERVICE(other)->state == SERVICE_RUNNING)
                busname_set_state(n, BUSNAME_RUNNING);
}
开发者ID:achanda,项目名称:systemd,代码行数:26,代码来源:busname.c


示例5: busname_control_pid

static int busname_control_pid(Unit *u) {
        BusName *n = BUSNAME(u);

        assert(n);

        return n->control_pid;
}
开发者ID:achanda,项目名称:systemd,代码行数:7,代码来源:busname.c


示例6: busname_reset_failed

static void busname_reset_failed(Unit *u) {
        BusName *n = BUSNAME(u);

        assert(n);

        if (n->state == BUSNAME_FAILED)
                busname_set_state(n, BUSNAME_DEAD);

        n->result = BUSNAME_SUCCESS;
}
开发者ID:freedesktop-unofficial-mirror,项目名称:systemd__systemd,代码行数:10,代码来源:busname.c


示例7: busname_init

static void busname_init(Unit *u) {
        BusName *n = BUSNAME(u);

        assert(u);
        assert(u->load_state == UNIT_STUB);

        n->starter_fd = -1;
        n->accept_fd = true;
        n->activating = true;

        n->timeout_usec = u->manager->default_timeout_start_usec;
}
开发者ID:freedesktop-unofficial-mirror,项目名称:systemd__systemd,代码行数:12,代码来源:busname.c


示例8: busname_get_timeout

static int busname_get_timeout(Unit *u, uint64_t *timeout) {
        BusName *n = BUSNAME(u);
        int r;

        if (!n->timer_event_source)
                return 0;

        r = sd_event_source_get_time(n->timer_event_source, timeout);
        if (r < 0)
                return r;

        return 1;
}
开发者ID:freedesktop-unofficial-mirror,项目名称:systemd__systemd,代码行数:13,代码来源:busname.c


示例9: busname_done

static void busname_done(Unit *u) {
        BusName *n = BUSNAME(u);

        assert(n);

        n->name = mfree(n->name);

        busname_free_policy(n);
        busname_unwatch_control_pid(n);
        busname_close_fd(n);

        unit_ref_unset(&n->service);

        n->timer_event_source = sd_event_source_unref(n->timer_event_source);
}
开发者ID:achanda,项目名称:systemd,代码行数:15,代码来源:busname.c


示例10: busname_deserialize_item

static int busname_deserialize_item(Unit *u, const char *key, const char *value, FDSet *fds) {
        BusName *n = BUSNAME(u);

        assert(n);
        assert(key);
        assert(value);

        if (streq(key, "state")) {
                BusNameState state;

                state = busname_state_from_string(value);
                if (state < 0)
                        log_unit_debug(u->id, "Failed to parse state value %s", value);
                else
                        n->deserialized_state = state;

        } else if (streq(key, "result")) {
                BusNameResult f;

                f = busname_result_from_string(value);
                if (f < 0)
                        log_unit_debug(u->id, "Failed to parse result value %s", value);
                else if (f != BUSNAME_SUCCESS)
                        n->result = f;

        } else if (streq(key, "control-pid")) {
                pid_t pid;

                if (parse_pid(value, &pid) < 0)
                        log_unit_debug(u->id, "Failed to parse control-pid value %s", value);
                else
                        n->control_pid = pid;
        } else if (streq(key, "starter-fd")) {
                int fd;

                if (safe_atoi(value, &fd) < 0 || fd < 0 || !fdset_contains(fds, fd))
                        log_unit_debug(u->id, "Failed to parse starter fd value %s", value);
                else {
                        safe_close(n->starter_fd);
                        n->starter_fd = fdset_remove(fds, fd);
                }
        } else
                log_unit_debug(u->id, "Unknown serialization key '%s'", key);

        return 0;
}
开发者ID:freedesktop-unofficial-mirror,项目名称:systemd__systemd,代码行数:46,代码来源:busname.c


示例11: busname_get_timeout

static int busname_get_timeout(Unit *u, usec_t *timeout) {
        BusName *n = BUSNAME(u);
        usec_t t;
        int r;

        if (!n->timer_event_source)
                return 0;

        r = sd_event_source_get_time(n->timer_event_source, &t);
        if (r < 0)
                return r;
        if (t == USEC_INFINITY)
                return 0;

        *timeout = t;
        return 1;
}
开发者ID:achanda,项目名称:systemd,代码行数:17,代码来源:busname.c


示例12: busname_serialize

static int busname_serialize(Unit *u, FILE *f, FDSet *fds) {
        BusName *n = BUSNAME(u);
        int r;

        assert(n);
        assert(f);
        assert(fds);

        unit_serialize_item(u, f, "state", busname_state_to_string(n->state));
        unit_serialize_item(u, f, "result", busname_result_to_string(n->result));

        if (n->control_pid > 0)
                unit_serialize_item_format(u, f, "control-pid", PID_FMT, n->control_pid);

        r = unit_serialize_item_fd(u, f, fds, "starter-fd", n->starter_fd);
        if (r < 0)
                return r;

        return 0;
}
开发者ID:achanda,项目名称:systemd,代码行数:20,代码来源:busname.c


示例13: busname_load

static int busname_load(Unit *u) {
        BusName *n = BUSNAME(u);
        int r;

        assert(u);
        assert(u->load_state == UNIT_STUB);

        r = unit_load_fragment_and_dropin(u);
        if (r < 0)
                return r;

        if (u->load_state == UNIT_LOADED) {
                /* This is a new unit? Then let's add in some extras */
                r = busname_add_extras(n);
                if (r < 0)
                        return r;
        }

        return busname_verify(n);
}
开发者ID:freedesktop-unofficial-mirror,项目名称:systemd__systemd,代码行数:20,代码来源:busname.c


示例14: busname_stop

static int busname_stop(Unit *u) {
        BusName *n = BUSNAME(u);

        assert(n);

        /* Already on it */
        if (IN_SET(n->state, BUSNAME_SIGTERM, BUSNAME_SIGKILL))
                return 0;

        /* If there's already something running, we go directly into
         * kill mode. */

        if (n->state == BUSNAME_MAKING) {
                busname_enter_signal(n, BUSNAME_SIGTERM, BUSNAME_SUCCESS);
                return -EAGAIN;
        }

        assert(IN_SET(n->state, BUSNAME_REGISTERED, BUSNAME_LISTENING, BUSNAME_RUNNING));

        busname_enter_dead(n, BUSNAME_SUCCESS);
        return 1;
}
开发者ID:freedesktop-unofficial-mirror,项目名称:systemd__systemd,代码行数:22,代码来源:busname.c


示例15: busname_coldplug

static int busname_coldplug(Unit *u, Hashmap *deferred_work) {
        BusName *n = BUSNAME(u);
        int r;

        assert(n);
        assert(n->state == BUSNAME_DEAD);

        if (n->deserialized_state == n->state)
                return 0;

        if (IN_SET(n->deserialized_state, BUSNAME_MAKING, BUSNAME_SIGTERM, BUSNAME_SIGKILL)) {

                if (n->control_pid <= 0)
                        return -EBADMSG;

                r = unit_watch_pid(UNIT(n), n->control_pid);
                if (r < 0)
                        return r;

                r = busname_arm_timer(n);
                if (r < 0)
                        return r;
        }

        if (IN_SET(n->deserialized_state, BUSNAME_MAKING, BUSNAME_LISTENING, BUSNAME_REGISTERED, BUSNAME_RUNNING)) {
                r = busname_open_fd(n);
                if (r < 0)
                        return r;
        }

        if (n->deserialized_state == BUSNAME_LISTENING) {
                r = busname_watch_fd(n);
                if (r < 0)
                        return r;
        }

        busname_set_state(n, n->deserialized_state);
        return 0;
}
开发者ID:freedesktop-unofficial-mirror,项目名称:systemd__systemd,代码行数:39,代码来源:busname.c


示例16: busname_coldplug

static int busname_coldplug(Unit *u) {
        BusName *n = BUSNAME(u);
        int r;

        assert(n);
        assert(n->state == BUSNAME_DEAD);

        if (n->deserialized_state == n->state)
                return 0;

        if (n->control_pid > 0 &&
            pid_is_unwaited(n->control_pid) &&
            IN_SET(n->deserialized_state, BUSNAME_MAKING, BUSNAME_SIGTERM, BUSNAME_SIGKILL)) {

                r = unit_watch_pid(UNIT(n), n->control_pid);
                if (r < 0)
                        return r;

                r = busname_arm_timer(n, usec_add(u->state_change_timestamp.monotonic, n->timeout_usec));
                if (r < 0)
                        return r;
        }

        if (IN_SET(n->deserialized_state, BUSNAME_MAKING, BUSNAME_LISTENING, BUSNAME_REGISTERED, BUSNAME_RUNNING)) {
                r = busname_open_fd(n);
                if (r < 0)
                        return r;
        }

        if (n->deserialized_state == BUSNAME_LISTENING) {
                r = busname_watch_fd(n);
                if (r < 0)
                        return r;
        }

        busname_set_state(n, n->deserialized_state);
        return 0;
}
开发者ID:achanda,项目名称:systemd,代码行数:38,代码来源:busname.c


示例17: busname_dump

static void busname_dump(Unit *u, FILE *f, const char *prefix) {
        BusName *n = BUSNAME(u);

        assert(n);
        assert(f);

        fprintf(f,
                "%sBus Name State: %s\n"
                "%sResult: %s\n"
                "%sName: %s\n"
                "%sActivating: %s\n"
                "%sAccept FD: %s\n",
                prefix, busname_state_to_string(n->state),
                prefix, busname_result_to_string(n->result),
                prefix, n->name,
                prefix, yes_no(n->activating),
                prefix, yes_no(n->accept_fd));

        if (n->control_pid > 0)
                fprintf(f,
                        "%sControl PID: "PID_FMT"\n",
                        prefix, n->control_pid);
}
开发者ID:freedesktop-unofficial-mirror,项目名称:systemd__systemd,代码行数:23,代码来源:busname.c


示例18: busname_trigger_notify

static void busname_trigger_notify(Unit *u, Unit *other) {
        BusName *n = BUSNAME(u);
        Service *s;

        assert(n);
        assert(other);

        if (!IN_SET(n->state, BUSNAME_RUNNING, BUSNAME_LISTENING))
                return;

        if (other->load_state != UNIT_LOADED || other->type != UNIT_SERVICE)
                return;

        s = SERVICE(other);

        if (s->state == SERVICE_FAILED && s->result == SERVICE_FAILURE_START_LIMIT)
                busname_enter_dead(n, BUSNAME_FAILURE_SERVICE_FAILED_PERMANENT);
        else if (IN_SET(s->state,
                        SERVICE_DEAD, SERVICE_FAILED,
                        SERVICE_STOP, SERVICE_STOP_SIGTERM, SERVICE_STOP_SIGKILL,
                        SERVICE_STOP_POST, SERVICE_FINAL_SIGTERM, SERVICE_FINAL_SIGKILL,
                        SERVICE_AUTO_RESTART))
                busname_enter_listening(n);
}
开发者ID:freedesktop-unofficial-mirror,项目名称:systemd__systemd,代码行数:24,代码来源:busname.c


示例19: busname_kill

static int busname_kill(Unit *u, KillWho who, int signo, sd_bus_error *error) {
        return unit_kill_common(u, who, signo, -1, BUSNAME(u)->control_pid, error);
}
开发者ID:freedesktop-unofficial-mirror,项目名称:systemd__systemd,代码行数:3,代码来源:busname.c


示例20: busname_peek_message

static int busname_peek_message(BusName *n) {
        struct kdbus_cmd_recv cmd_recv = {
                .size = sizeof(cmd_recv),
                .flags = KDBUS_RECV_PEEK,
        };
        struct kdbus_cmd_free cmd_free = {
                .size = sizeof(cmd_free),
        };
        const char *comm = NULL;
        struct kdbus_item *d;
        struct kdbus_msg *k;
        size_t start, ps, sz, delta;
        void *p = NULL;
        pid_t pid = 0;
        int r;

        /* Generate a friendly debug log message about which process
         * caused triggering of this bus name. This simply peeks the
         * metadata of the first queued message and logs it. */

        assert(n);

        /* Let's shortcut things a bit, if debug logging is turned off
         * anyway. */

        if (log_get_max_level() < LOG_DEBUG)
                return 0;

        r = ioctl(n->starter_fd, KDBUS_CMD_RECV, &cmd_recv);
        if (r < 0) {
                if (errno == EINTR || errno == EAGAIN)
                        return 0;

                log_unit_error(UNIT(n)->id, "%s: Failed to query activation message: %m", UNIT(n)->id);
                return -errno;
        }

        /* We map as late as possible, and unmap imemdiately after
         * use. On 32bit address space is scarce and we want to be
         * able to handle a lot of activator connections at the same
         * time, and hence shouldn't keep the mmap()s around for
         * longer than necessary. */

        ps = page_size();
        start = (cmd_recv.msg.offset / ps) * ps;
        delta = cmd_recv.msg.offset - start;
        sz = PAGE_ALIGN(delta + cmd_recv.msg.msg_size);

        p = mmap(NULL, sz, PROT_READ, MAP_SHARED, n->starter_fd, start);
        if (p == MAP_FAILED) {
                log_unit_error(UNIT(n)->id, "%s: Failed to map activation message: %m", UNIT(n)->id);
                r = -errno;
                goto finish;
        }

        k = (struct kdbus_msg *) ((uint8_t *) p + delta);
        KDBUS_ITEM_FOREACH(d, k, items) {
                switch (d->type) {

                case KDBUS_ITEM_PIDS:
                        pid = d->pids.pid;
                        break;

                case KDBUS_ITEM_PID_COMM:
                        comm = d->str;
                        break;
                }
        }

        if (pid > 0)
                log_unit_debug(UNIT(n)->id, "%s: Activation triggered by process " PID_FMT " (%s)", UNIT(n)->id, pid, strna(comm));

        r = 0;

finish:
        if (p)
                (void) munmap(p, sz);

        cmd_free.offset = cmd_recv.msg.offset;
        if (ioctl(n->starter_fd, KDBUS_CMD_FREE, &cmd_free) < 0)
                log_unit_warning(UNIT(n)->id, "Failed to free peeked message, ignoring: %m");

        return r;
}

static int busname_dispatch_io(sd_event_source *source, int fd, uint32_t revents, void *userdata) {
        BusName *n = userdata;

        assert(n);
        assert(fd >= 0);

        if (n->state != BUSNAME_LISTENING)
                return 0;

        log_unit_debug(UNIT(n)->id, "Activation request on %s", UNIT(n)->id);

        if (revents != EPOLLIN) {
                log_unit_error(UNIT(n)->id, "%s: Got unexpected poll event (0x%x) on starter fd.",
                               UNIT(n)->id, revents);
                goto fail;
//.........这里部分代码省略.........
开发者ID:freedesktop-unofficial-mirror,项目名称:systemd__systemd,代码行数:101,代码来源:busname.c



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
C++ BUSTYPE函数代码示例发布时间:2022-05-30
下一篇:
C++ BURN_ENDIAN_SWAP_INT16函数代码示例发布时间: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