goto error;
}
+ r = sd_event_source_set_name(source->event, name);
+ if (r < 0) {
+ log_error("Failed to set source name for fd:%d: %s", fd, strerror(-r));
+ goto error;
+ }
+
return 1; /* work to do */
error:
static int add_raw_socket(RemoteServer *s, int fd) {
int r;
+ _cleanup_close_ int fd_ = fd;
+ char name[strlen("raw-socket-") + DECIMAL_STR_MAX(int)];
+
+ assert(fd >= 0);
r = sd_event_add_io(s->events, &s->listen_event,
fd, EPOLLIN,
dispatch_raw_connection_event, s);
- if (r < 0) {
- close(fd);
+ if (r < 0)
+ return r;
+
+ snprintf(name, sizeof(name), "raw-socket-%d", fd);
+
+ r = sd_event_source_set_name(s->listen_event, name);
+ if (r < 0)
return r;
- }
+ fd_ = -1;
s->active ++;
return 0;
}
goto error;
}
+ r = sd_event_source_set_name(d->event, "epoll-fd");
+ if (r < 0) {
+ log_error("Failed to set source name: %s", strerror(-r));
+ goto error;
+ }
+
r = hashmap_ensure_allocated(&s->daemons, &uint64_hash_ops);
if (r < 0) {
log_oom();
**********************************************************************
**********************************************************************/
-static int dispatch_sigterm(sd_event_source *event,
- const struct signalfd_siginfo *si,
- void *userdata) {
- RemoteServer *s = userdata;
-
- assert(s);
-
- log_received_signal(LOG_INFO, si);
-
- sd_event_exit(s->events, 0);
- return 0;
-}
-
static int setup_signals(RemoteServer *s) {
sigset_t mask;
int r;
sigset_add_many(&mask, SIGINT, SIGTERM, -1);
assert_se(sigprocmask(SIG_SETMASK, &mask, NULL) == 0);
- r = sd_event_add_signal(s->events, &s->sigterm_event, SIGTERM, dispatch_sigterm, s);
+ r = sd_event_add_signal(s->events, &s->sigterm_event, SIGTERM, NULL, s);
+ if (r < 0)
+ return r;
+
+ r = sd_event_source_set_name(s->sigterm_event, "sigterm");
+ if (r < 0)
+ return r;
+
+ r = sd_event_add_signal(s->events, &s->sigint_event, SIGINT, NULL, s);
if (r < 0)
return r;
- r = sd_event_add_signal(s->events, &s->sigint_event, SIGINT, dispatch_sigterm, s);
+ r = sd_event_source_set_name(s->sigint_event, "sigint");
if (r < 0)
return r;