From owner-freebsd-net Mon Feb 26 15: 6:22 2001 Delivered-To: freebsd-net@freebsd.org Received: from curly.chiaro.com (us.chiaro.com [63.88.196.33]) by hub.freebsd.org (Postfix) with ESMTP id 59E3237B491 for ; Mon, 26 Feb 2001 15:06:17 -0800 (PST) (envelope-from plawthers@chiaro.com) Received: from chiaro.com (192-168-25-122.chiaro.com [192.168.25.122]) by curly.chiaro.com (8.9.3+Sun/8.9.1) with ESMTP id RAA20515; Mon, 26 Feb 2001 17:06:16 -0600 (CST) Message-ID: <3A9AE15D.103DFBB7@chiaro.com> Date: Mon, 26 Feb 2001 17:06:05 -0600 From: Peter Lawthers Organization: Chiaro Networks X-Mailer: Mozilla 4.75 [en] (Windows NT 5.0; U) X-Accept-Language: en MIME-Version: 1.0 To: freebsd-net@freebsd.org Subject: sendfile with headers (struct sf_hdtr) Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit Sender: owner-freebsd-net@FreeBSD.ORG Precedence: bulk X-Loop: FreeBSD.org 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