From owner-cvs-all Fri Nov 6 08:02:56 1998 Return-Path: Received: (from majordom@localhost) by hub.freebsd.org (8.8.8/8.8.8) id IAA15911 for cvs-all-outgoing; Fri, 6 Nov 1998 08:02:56 -0800 (PST) (envelope-from owner-cvs-all@FreeBSD.ORG) Received: from implode.root.com (implode.root.com [198.145.90.17]) by hub.freebsd.org (8.8.8/8.8.8) with ESMTP id IAA15887; Fri, 6 Nov 1998 08:02:49 -0800 (PST) (envelope-from xroot@implode.root.com) Received: from implode.root.com (localhost [127.0.0.1]) by implode.root.com (8.8.5/8.8.5) with ESMTP id IAA18481; Fri, 6 Nov 1998 08:03:44 -0800 (PST) Message-Id: <199811061603.IAA18481@implode.root.com> To: Matthew Dillon cc: cvs-committers@FreeBSD.ORG, cvs-all@FreeBSD.ORG Subject: Re: sendfile.2 (was Re: cvs commit: ...) In-reply-to: Your message of "Thu, 05 Nov 1998 18:56:46 PST." <199811060256.SAA00345@apollo.backplane.com> From: David Greenman Reply-To: dg@root.com Date: Fri, 06 Nov 1998 08:03:44 -0800 Sender: owner-cvs-all@FreeBSD.ORG Precedence: bulk Matt, please try out the attached patches that provide non-blocking support for sendfile(2). It works like this: If the socket is set non-blocking, then sendfile(2) will send as much as it can and if there is still more to send, it will return EAGAIN and return the number of bytes written to the socket in *sbytes. The application will need to keep track of the number of bytes written and adjust the file offset accordingly for subsequant sendfile(2) calls. Further, if headers/trailers are specified, then the application will need to figure out the mess and rebuild the iovecs as appropriate. -DG David Greenman Co-founder/Principal Architect, The FreeBSD Project Index: uipc_syscalls.c =================================================================== RCS file: /home/ncvs/src/sys/kern/uipc_syscalls.c,v retrieving revision 1.42 diff -c -r1.42 uipc_syscalls.c *** uipc_syscalls.c 1998/11/05 14:28:24 1.42 --- uipc_syscalls.c 1998/11/06 15:55:30 *************** *** 1506,1511 **** --- 1506,1523 ---- if (xfsize <= 0) break; /* + * Optimize the non-blocking case by looking at the socket space + * before going to the extra work of constituting the sf_buf. + */ + if ((so->so_state & SS_NBIO) && sbspace(&so->so_snd) <= 0) { + if (so->so_state & SS_CANTSENDMORE) + error = EPIPE; + else + error = EAGAIN; + sbunlock(&so->so_snd); + goto done; + } + /* * Attempt to look up the page. If the page doesn't exist or the * part we're interested in isn't valid, then read it from disk. * If some other part of the kernel has this page (i.e. it's busy), *************** *** 1634,1639 **** --- 1646,1658 ---- * a race condition with sbwait(). */ if (sbspace(&so->so_snd) <= 0) { + if (so->so_state & SS_NBIO) { + m_freem(m); + sbunlock(&so->so_snd); + splx(s); + error = EAGAIN; + goto done; + } error = sbwait(&so->so_snd); /* * An error from sbwait usually indicates that we've To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe cvs-all" in the body of the message