Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 26 Feb 2001 17:06:05 -0600
From:      Peter Lawthers <plawthers@chiaro.com>
To:        freebsd-net@freebsd.org
Subject:   sendfile with headers (struct sf_hdtr)
Message-ID:  <3A9AE15D.103DFBB7@chiaro.com>

next in thread | raw e-mail | index | archive | help
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 majordomo@FreeBSD.org
with "unsubscribe freebsd-net" in the body of the message




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?3A9AE15D.103DFBB7>