***/
#include <sys/socket.h>
-#include <sys/poll.h>
-#include <sys/types.h>
+#include <poll.h>
#include <sys/timerfd.h>
-#include <assert.h>
-#include <string.h>
#include <errno.h>
#include <unistd.h>
-#include <fcntl.h>
#include <stddef.h>
#include "systemd/sd-daemon.h"
assert(fd >= 0);
assert(_b);
- n = recvmsg(fd, &msghdr, MSG_DONTWAIT|MSG_CMSG_CLOEXEC);
- if (n <= 0) {
- if (n == 0) {
- log_error("Short read");
- return -EIO;
- }
-
+ n = recvmsg(fd, &msghdr, MSG_DONTWAIT);
+ if (n < 0) {
if (errno == EAGAIN || errno == EINTR)
return 0;
return -errno;
}
+ cmsg_close_all(&msghdr);
+
+ if (n == 0) {
+ log_error("Short read");
+ return -EIO;
+ }
+
if (msghdr.msg_controllen < CMSG_LEN(sizeof(struct ucred)) ||
control.cmsghdr.cmsg_level != SOL_SOCKET ||
control.cmsghdr.cmsg_type != SCM_CREDENTIALS ||