diff options
author | dg <dg@FreeBSD.org> | 1998-11-06 19:16:30 +0000 |
---|---|---|
committer | dg <dg@FreeBSD.org> | 1998-11-06 19:16:30 +0000 |
commit | bbf3dfad8860abb83773e18cdf6c5e37a516f1bb (patch) | |
tree | 1df8d98258e4e1843532af843d7fbffc99bf920a /sys/kern/uipc_syscalls.c | |
parent | c03894d4903383aca188746e152353a439cefb2b (diff) | |
download | FreeBSD-src-bbf3dfad8860abb83773e18cdf6c5e37a516f1bb.zip FreeBSD-src-bbf3dfad8860abb83773e18cdf6c5e37a516f1bb.tar.gz |
Added support for non-blocking sockets to sendfile(2).
Diffstat (limited to 'sys/kern/uipc_syscalls.c')
-rw-r--r-- | sys/kern/uipc_syscalls.c | 21 |
1 files changed, 20 insertions, 1 deletions
diff --git a/sys/kern/uipc_syscalls.c b/sys/kern/uipc_syscalls.c index f0cca24..65ea00d 100644 --- a/sys/kern/uipc_syscalls.c +++ b/sys/kern/uipc_syscalls.c @@ -34,7 +34,7 @@ * SUCH DAMAGE. * * @(#)uipc_syscalls.c 8.4 (Berkeley) 2/21/94 - * $Id: uipc_syscalls.c,v 1.41 1998/08/23 03:06:59 wollman Exp $ + * $Id: uipc_syscalls.c,v 1.42 1998/11/05 14:28:24 dg Exp $ */ #include "opt_compat.h" @@ -1506,6 +1506,18 @@ retry_lookup: 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,6 +1646,13 @@ retry_space: * 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 |