aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--sys/kern/kern_sendfile.c9
1 files changed, 6 insertions, 3 deletions
diff --git a/sys/kern/kern_sendfile.c b/sys/kern/kern_sendfile.c
index b4ad28b27b36..a14b88b2169e 100644
--- a/sys/kern/kern_sendfile.c
+++ b/sys/kern/kern_sendfile.c
@@ -637,6 +637,7 @@ sendfile_getsock(struct thread *td, int s, struct file **sock_fp,
int
sendfile_wait_generic(struct socket *so, off_t need, int *space)
{
+ u_int lowat, newlowat;
int error;
MPASS(need > 0);
@@ -657,9 +658,11 @@ sendfile_wait_generic(struct socket *so, off_t need, int *space)
*/
error = 0;
SOCK_SENDBUF_LOCK(so);
+ lowat = so->so_snd.sb_lowat;
if (so->so_snd.sb_flags & SB_AUTOLOWAT) {
- if (so->so_snd.sb_lowat < so->so_snd.sb_hiwat / 2)
- so->so_snd.sb_lowat = so->so_snd.sb_hiwat / 2;
+ newlowat = min(V_tcp_sendspace, so->so_snd.sb_hiwat) / 2;
+ if (so->so_snd.sb_lowat < newlowat)
+ so->so_snd.sb_lowat = newlowat;
if (so->so_snd.sb_lowat < PAGE_SIZE &&
so->so_snd.sb_hiwat >= PAGE_SIZE)
so->so_snd.sb_lowat = PAGE_SIZE;
@@ -679,7 +682,7 @@ retry_space:
}
*space = sbspace(&so->so_snd);
- if (*space < need && (*space <= 0 || *space < so->so_snd.sb_lowat)) {
+ if (*space < need && (*space <= 0 || *space < lowat)) {
if (so->so_state & SS_NBIO) {
error = EAGAIN;
goto done;