本文整理汇总了C++中BUSNAME函数的典型用法代码示例。如果您正苦于以下问题:C++ BUSNAME函数的具体用法?C++ BUSNAME怎么用?C++ BUSNAME使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了BUSNAME函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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;
}
示例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;
}
示例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;
}
示例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);
}
示例5: busname_control_pid
static int busname_control_pid(Unit *u) {
BusName *n = BUSNAME(u);
assert(n);
return n->control_pid;
}
示例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;
}
示例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;
}
示例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;
}
示例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);
}
示例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;
}
示例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;
}
示例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;
}
示例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);
}
示例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;
}
示例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;
}