When using sendfile(2) with the optional headers, it appears
that sendfile inadvertently returns the number of bytes written
via writev (writev updates p_retval[0]). I checked through the
archives, and it doesn't appear that I'm using sendfile(2) incorrectly,
although that's always a possibility.
What happens is that sendfile(2) always returns the number of
header/trailer
bytes written, rather than the errno.
What's the accepted procedure for logging this? You can hit this
is you specify the optional headers to sendfile, thusly:
struct sf_hdtr hdr;
....
bzero(&hdr, sizeof(hdr);
hdr.headers = &iov; /* iov set up elsewhere */
hdr.hdr_cnt = 1;
error = sendfile(fd, sockfd, 0, 0, &hdr, &sendbytes, 0);
Here's a diff of what I changed to make it happy. I believe this
to be "safe", but I'm certain someone out there knows more than
me and can tell me why I'm wrong. :-)
diff -aur sys/kern/uipc_syscalls.c /tmp/bsd/src/sys/kern/uipc_syscalls.c
--- sys/kern/uipc_syscalls.c Mon Feb 26 16:15:26 2001
+++ /tmp/bsd/src/sys/kern/uipc_syscalls.c Tue Aug 15 14:29:27 2000
@@ -1552,7 +1552,6 @@
if (error)
goto done;
sbytes += p->p_retval[0];
- p->p_retval[0] = 0;
}
}
@@ -1773,7 +1772,6 @@
if (error)
goto done;
sbytes += p->p_retval[0];
- p->p_retval[0] = 0;
}
done:
To Unsubscribe: send mail to [EMAIL PROTECTED]
with "unsubscribe freebsd-net" in the body of the message