本文整理汇总了C++中sd_event_exit函数的典型用法代码示例。如果您正苦于以下问题:C++ sd_event_exit函数的具体用法?C++ sd_event_exit怎么用?C++ sd_event_exit使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了sd_event_exit函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: test_client_solicit_cb
static void test_client_solicit_cb(sd_dhcp6_client *client, int event,
void *userdata) {
sd_event *e = userdata;
sd_dhcp6_lease *lease;
struct in6_addr *addrs;
char **domains;
assert_se(e);
assert_se(event == SD_DHCP6_CLIENT_EVENT_IP_ACQUIRE);
assert_se(sd_dhcp6_client_get_lease(client, &lease) >= 0);
assert_se(sd_dhcp6_lease_get_domains(lease, &domains) == 1);
assert_se(!strcmp("lab.intra", domains[0]));
assert_se(domains[1] == NULL);
assert_se(sd_dhcp6_lease_get_dns(lease, &addrs) == 1);
assert_se(!memcmp(addrs, &msg_advertise[124], 16));
assert_se(sd_dhcp6_lease_get_ntp_addrs(lease, &addrs) == 1);
assert_se(!memcmp(addrs, &msg_advertise[159], 16));
assert_se(sd_dhcp6_client_set_request_option(client, SD_DHCP6_OPTION_DNS_SERVERS) == -EBUSY);
if (verbose)
printf(" got DHCPv6 event %d\n", event);
sd_event_exit(e, 0);
}
示例2: cli_handler_fn
static void cli_handler_fn(char *input)
{
_shl_free_ char *original = input;
_shl_strv_free_ char **args = NULL;
int r;
if (!input) {
rl_insert_text("quit");
rl_redisplay();
rl_crlf();
sd_event_exit(cli_event, 0);
return;
}
r = shl_qstr_tokenize(input, &args);
if (r < 0)
return cli_vENOMEM();
else if (!r)
return;
add_history(original);
r = cli_do(cli_cmds, args, r);
if (r != -EAGAIN)
return;
cli_printf("Command not found\n");
}
示例3: on_properties_changed
static int on_properties_changed(sd_bus_message *m, void *userdata, sd_bus_error *error) {
static const struct bus_properties_map map[] = {
{ "ActiveState", "s", NULL, offsetof(RunContext, active_state) },
{ "InactiveExitTimestampMonotonic", "t", NULL, offsetof(RunContext, inactive_exit_usec) },
{ "InactiveEnterTimestampMonotonic", "t", NULL, offsetof(RunContext, inactive_enter_usec) },
{ "Result", "s", NULL, offsetof(RunContext, result) },
{ "ExecMainCode", "i", NULL, offsetof(RunContext, exit_code) },
{ "ExecMainStatus", "i", NULL, offsetof(RunContext, exit_status) },
{ "CPUUsageNSec", "t", NULL, offsetof(RunContext, cpu_usage_nsec) },
{}
};
RunContext *c = userdata;
int r;
r = bus_map_all_properties(c->bus,
"org.freedesktop.systemd1",
sd_bus_message_get_path(m),
map,
c);
if (r < 0) {
sd_event_exit(c->event, EXIT_FAILURE);
return log_error_errno(r, "Failed to query unit state: %m");
}
run_context_check_done(c);
return 0;
}
示例4: test_rs_done
static void test_rs_done(sd_icmp6_nd *nd, int event, void *userdata) {
sd_event *e = userdata;
static int idx = 0;
struct {
uint8_t flag;
int event;
} flag_event[] = {
{ 0, ICMP6_EVENT_ROUTER_ADVERTISMENT_NONE },
{ ND_RA_FLAG_OTHER, ICMP6_EVENT_ROUTER_ADVERTISMENT_OTHER },
{ ND_RA_FLAG_MANAGED, ICMP6_EVENT_ROUTER_ADVERTISMENT_MANAGED }
};
uint32_t mtu;
assert_se(nd);
assert_se(event == flag_event[idx].event);
idx++;
if (verbose)
printf(" got event %d\n", event);
if (idx < 3) {
send_ra(flag_event[idx].flag);
return;
}
assert_se(sd_icmp6_ra_get_mtu(nd, &mtu) == -ENOMSG);
sd_event_exit(e, 0);
}
示例5: cli_exit
void cli_exit(void)
{
if (!cli_event)
return cli_vEINVAL();
sd_event_exit(cli_event, 0);
}
示例6: pty_fn
static int pty_fn(Pty *pty, void *userdata, unsigned int ev, const void *ptr, size_t size) {
switch (ev) {
case PTY_DATA:
assert_se(rcvsiz < strlen(rcvmsg) * 2);
assert_se(rcvsiz + size < sizeof(rcvbuf));
memcpy(&rcvbuf[rcvsiz], ptr, size);
rcvsiz += size;
if (rcvsiz >= strlen(rcvmsg) * 2) {
assert_se(rcvsiz == strlen(rcvmsg) * 2);
assert_se(!memcmp(rcvbuf, rcvmsg, strlen(rcvmsg)));
assert_se(!memcmp(&rcvbuf[strlen(rcvmsg)], rcvmsg, strlen(rcvmsg)));
}
break;
case PTY_HUP:
/* This is guaranteed to appear _after_ the input queues are
* drained! */
assert_se(rcvsiz == strlen(rcvmsg) * 2);
break;
case PTY_CHILD:
/* this may appear at any time */
break;
default:
assert_se(0);
break;
}
/* if we got HUP _and_ CHILD, exit */
if (pty_get_fd(pty) < 0 && pty_get_child(pty) < 0)
sd_event_exit(event, 0);
return 0;
}
示例7: test_rs_done
static void test_rs_done(sd_ndisc *nd, uint8_t flags, const struct in6_addr *gateway, unsigned lifetime, int pref, void *userdata) {
sd_event *e = userdata;
static unsigned idx = 0;
uint8_t flags_array[] = {
0,
0,
0,
ND_RA_FLAG_OTHER,
ND_RA_FLAG_MANAGED
};
uint32_t mtu;
assert_se(nd);
assert_se(flags == flags_array[idx]);
idx++;
if (verbose)
printf(" got event 0x%02x\n", flags);
if (idx < ELEMENTSOF(flags_array)) {
send_ra(flags_array[idx]);
return;
}
assert_se(sd_ndisc_get_mtu(nd, &mtu) == -ENOMSG);
sd_event_exit(e, 0);
}
示例8: test_addr_acq_acquired
static void test_addr_acq_acquired(sd_dhcp_client *client, int event,
void *userdata) {
sd_event *e = userdata;
sd_dhcp_lease *lease;
struct in_addr addr;
assert_se(client);
assert_se(event == SD_DHCP_CLIENT_EVENT_IP_ACQUIRE);
assert_se(sd_dhcp_client_get_lease(client, &lease) >= 0);
assert_se(lease);
assert_se(sd_dhcp_lease_get_address(lease, &addr) >= 0);
assert_se(memcmp(&addr.s_addr, &test_addr_acq_ack[44],
sizeof(addr.s_addr)) == 0);
assert_se(sd_dhcp_lease_get_netmask(lease, &addr) >= 0);
assert_se(memcmp(&addr.s_addr, &test_addr_acq_ack[285],
sizeof(addr.s_addr)) == 0);
assert_se(sd_dhcp_lease_get_router(lease, &addr) >= 0);
assert_se(memcmp(&addr.s_addr, &test_addr_acq_ack[308],
sizeof(addr.s_addr)) == 0);
if (verbose)
printf(" DHCP address acquired\n");
sd_event_exit(e, 0);
}
示例9: accept_cb
static int accept_cb(sd_event_source *s, int fd, uint32_t revents, void *userdata) {
_cleanup_free_ char *peer = NULL;
Context *context = userdata;
int nfd = -1, r;
assert(s);
assert(fd >= 0);
assert(revents & EPOLLIN);
assert(context);
nfd = accept4(fd, NULL, NULL, SOCK_NONBLOCK|SOCK_CLOEXEC);
if (nfd < 0) {
if (errno != -EAGAIN)
log_warning_errno(errno, "Failed to accept() socket: %m");
} else {
getpeername_pretty(nfd, true, &peer);
log_debug("New connection from %s", strna(peer));
r = add_connection_socket(context, nfd);
if (r < 0) {
log_error_errno(r, "Failed to accept connection, ignoring: %m");
safe_close(fd);
}
}
r = sd_event_source_set_enabled(s, SD_EVENT_ONESHOT);
if (r < 0) {
log_error_errno(r, "Error while re-enabling listener with ONESHOT: %m");
sd_event_exit(context->event, r);
return r;
}
return 1;
}
示例10: evcat_idev_fn
static int evcat_idev_fn(idev_session *session, void *userdata, idev_event *ev) {
Evcat *e = userdata;
switch (ev->type) {
case IDEV_EVENT_DEVICE_ADD:
idev_device_enable(ev->device_add.device);
break;
case IDEV_EVENT_DEVICE_REMOVE:
idev_device_disable(ev->device_remove.device);
break;
case IDEV_EVENT_DEVICE_DATA:
switch (ev->device_data.data.type) {
case IDEV_DATA_KEYBOARD:
if (kdata_is_exit(&ev->device_data.data))
sd_event_exit(e->event, 0);
else
kdata_print(&ev->device_data.data);
break;
}
break;
}
return 0;
}
示例11: on_tar_finished
static void on_tar_finished(TarImport *import, int error, void *userdata) {
sd_event *event = userdata;
assert(import);
if (error == 0)
log_info("Operation completed successfully.");
sd_event_exit(event, abs(error));
}
示例12: on_dkr_finished
static void on_dkr_finished(DkrPull *pull, int error, void *userdata) {
sd_event *event = userdata;
assert(pull);
if (error == 0)
log_info("Operation completed successfully.");
sd_event_exit(event, abs(error));
}
示例13: dispatch_sigterm
static int dispatch_sigterm(sd_event_source *es, const struct signalfd_siginfo *si, void *userdata) {
Manager *m = userdata;
assert(m);
log_received_signal(LOG_INFO, si);
sd_event_exit(m->event, 0);
return 0;
}
示例14: on_finished
static void on_finished(DckImport *import, int error, void *userdata) {
sd_event *event = userdata;
assert(import);
if (error == 0)
log_info("Operation completed successfully.");
else
log_info_errno(error, "Operation failed: %m");
sd_event_exit(event, error);
}
示例15: name_owner_change_callback
static int name_owner_change_callback(sd_bus_message *m, void *userdata, sd_bus_error *ret_error) {
sd_event *e = userdata;
assert(m);
assert(e);
sd_bus_close(sd_bus_message_get_bus(m));
sd_event_exit(e, 0);
return 1;
}