tree-wide: port more code to use send_one_fd() and receive_one_fd()
Also, make it slightly more powerful, by accepting a flags argument, and make it safe for handling if more than one cmsg attribute happens to be attached.
This commit is contained in:
@@ -212,11 +212,6 @@ _public_ int sd_journal_sendv(const struct iovec *iov, int n) {
|
||||
.msg_namelen = offsetof(struct sockaddr_un, sun_path) + strlen(sa.sun_path),
|
||||
};
|
||||
ssize_t k;
|
||||
union {
|
||||
struct cmsghdr cmsghdr;
|
||||
uint8_t buf[CMSG_SPACE(sizeof(int))];
|
||||
} control;
|
||||
struct cmsghdr *cmsg;
|
||||
bool have_syslog_identifier = false;
|
||||
bool seal = true;
|
||||
|
||||
@@ -335,26 +330,7 @@ _public_ int sd_journal_sendv(const struct iovec *iov, int n) {
|
||||
return r;
|
||||
}
|
||||
|
||||
mh.msg_iov = NULL;
|
||||
mh.msg_iovlen = 0;
|
||||
|
||||
zero(control);
|
||||
mh.msg_control = &control;
|
||||
mh.msg_controllen = sizeof(control);
|
||||
|
||||
cmsg = CMSG_FIRSTHDR(&mh);
|
||||
cmsg->cmsg_level = SOL_SOCKET;
|
||||
cmsg->cmsg_type = SCM_RIGHTS;
|
||||
cmsg->cmsg_len = CMSG_LEN(sizeof(int));
|
||||
memcpy(CMSG_DATA(cmsg), &buffer_fd, sizeof(int));
|
||||
|
||||
mh.msg_controllen = cmsg->cmsg_len;
|
||||
|
||||
k = sendmsg(fd, &mh, MSG_NOSIGNAL);
|
||||
if (k < 0)
|
||||
return -errno;
|
||||
|
||||
return 0;
|
||||
return send_one_fd(fd, buffer_fd, 0);
|
||||
}
|
||||
|
||||
static int fill_iovec_perror_and_send(const char *message, int skip, struct iovec iov[]) {
|
||||
|
||||
Reference in New Issue
Block a user