summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKeith Packard <keithp@keithp.com>2013-11-02 19:23:41 -0700
committerKeith Packard <keithp@keithp.com>2013-11-02 19:23:41 -0700
commita7094c389ac9fd5ca265996f76eb55cb1133974b (patch)
tree4b5f00aeeb51199fe449e42a11b1f30d5cec9bf5
parent58151f63553faf81babd1371770b7a7f33cecac1 (diff)
Add SEND_FDS version of Readv
Now that we've found that libFS uses readv, we can test whether this readv implementation works correctly. Signed-off-by: Keith Packard <keithp@keithp.com>
-rw-r--r--Xtranssock.c24
1 files changed, 24 insertions, 0 deletions
diff --git a/Xtranssock.c b/Xtranssock.c
index 23150b2..84e4dcd 100644
--- a/Xtranssock.c
+++ b/Xtranssock.c
@@ -2273,7 +2273,31 @@ TRANS(SocketReadv) (XtransConnInfo ciptr, struct iovec *buf, int size)
{
prmsg (2,"SocketReadv(%d,%p,%d)\n", ciptr->fd, buf, size);
+#if XTRANS_SEND_FDS
+ {
+ struct msghdr msg;
+ struct fd_pass pass;
+
+ init_msg_recv(&msg, buf, size, &pass, MAX_FDS);
+ size = recvmsg(ciptr->fd, &msg, 0);
+ if (size >= 0 && msg.msg_controllen > sizeof (struct cmsghdr)) {
+ if (pass.cmsghdr.cmsg_level == SOL_SOCKET &&
+ pass.cmsghdr.cmsg_type == SCM_RIGHTS &&
+ !((msg.msg_flags & MSG_TRUNC) ||
+ (msg.msg_flags & MSG_CTRUNC)))
+ {
+ int nfd = (msg.msg_controllen - sizeof (struct cmsghdr)) / sizeof (int);
+ int *fd = (int *) CMSG_DATA(&pass.cmsghdr);
+ int i;
+ for (i = 0; i < nfd; i++)
+ appendFd(&ciptr->recv_fds, fd[i], 0);
+ }
+ }
+ return size;
+ }
+#else
return READV (ciptr, buf, size);
+#endif
}