_cleanup_(udev_ctrl_disconnect_and_listen_againp) struct udev_ctrl *uctrl = NULL;
struct udev_ctrl_msg_wire msg_wire;
struct iovec iov = IOVEC_MAKE(&msg_wire, sizeof(struct udev_ctrl_msg_wire));
- char cred_msg[CMSG_SPACE(sizeof(struct ucred))];
+ CMSG_BUFFER_TYPE(CMSG_SPACE(sizeof(struct ucred))) control;
struct msghdr smsg = {
.msg_iov = &iov,
.msg_iovlen = 1,
- .msg_control = cred_msg,
- .msg_controllen = sizeof(cred_msg),
+ .msg_control = &control,
+ .msg_controllen = sizeof(control),
};
struct cmsghdr *cmsg;
struct ucred *cred;
if (size == 0)
return 0; /* Client disconnects? */
- size = recvmsg(fd, &smsg, 0);
- if (size < 0) {
- if (errno != EINTR)
- return log_error_errno(errno, "Failed to receive ctrl message: %m");
-
+ size = recvmsg_safe(fd, &smsg, 0);
+ if (size == -EINTR)
return 0;
- }
+ if (size < 0)
+ return log_error_errno(size, "Failed to receive ctrl message: %m");
cmsg_close_all(&smsg);
(void) sd_event_source_set_description(source_io, "udev-ctrl-wait-io");
if (timeout != USEC_INFINITY) {
- r = sd_event_add_time(uctrl->event, &source_timeout, clock_boottime_or_monotonic(),
- usec_add(now(clock_boottime_or_monotonic()), timeout),
- 0, NULL, INT_TO_PTR(-ETIMEDOUT));
+ r = sd_event_add_time_relative(
+ uctrl->event, &source_timeout, clock_boottime_or_monotonic(),
+ timeout,
+ 0, NULL, INT_TO_PTR(-ETIMEDOUT));
if (r < 0)
return r;