这篇教程C++ BUSNAME函数代码示例写得很实用,希望能帮到您。
本文整理汇总了C++中BUSNAME函数的典型用法代码示例。如果您正苦于以下问题:C++ BUSNAME函数的具体用法?C++ BUSNAME怎么用?C++ BUSNAME使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。 在下文中一共展示了BUSNAME函数的22个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。 示例1: busname_serializestatic 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,
示例2: busname_startstatic 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,
示例3: busname_dispatch_timerstatic 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,
示例4: busname_trigger_notifystatic 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,
示例5: busname_control_pidstatic int busname_control_pid(Unit *u) { BusName *n = BUSNAME(u); assert(n); return n->control_pid;}
开发者ID:achanda,项目名称:systemd,代码行数:7,
示例6: busname_reset_failedstatic 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,
示例7: busname_initstatic 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,
示例8: busname_get_timeoutstatic 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,
示例9: busname_donestatic 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,
示例10: busname_deserialize_itemstatic 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,
示例11: busname_get_timeoutstatic 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,
示例12: busname_serializestatic 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,
示例13: busname_loadstatic 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,
示例14: busname_stopstatic 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,
示例15: busname_coldplugstatic 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,
示例16: busname_coldplugstatic 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,
示例17: busname_dumpstatic 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,
示例18: busname_trigger_notifystatic 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,
示例19: busname_killstatic 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,
示例20: busname_peek_messagestatic 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,
示例21: assert_pure_ static const char *busname_sub_state_to_string(Unit *u) { assert(u); return busname_state_to_string(BUSNAME(u)->state);}
开发者ID:freedesktop-unofficial-mirror,项目名称:systemd__systemd,代码行数:5,
示例22: busname_active_state_pure_ static UnitActiveState busname_active_state(Unit *u) { assert(u); return state_translation_table[BUSNAME(u)->state];}
开发者ID:freedesktop-unofficial-mirror,项目名称:systemd__systemd,代码行数:5,
注:本文中的BUSNAME函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 C++ BUSTYPE函数代码示例 C++ BURN_ENDIAN_SWAP_INT16函数代码示例 |