Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 12 Nov 2014 10:03:11 +0000 (UTC)
From:      Gleb Smirnoff <glebius@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-projects@freebsd.org
Subject:   svn commit: r274422 - in projects/sendfile/sys: kern sys
Message-ID:  <201411121003.sACA3B3M078934@svn.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: glebius
Date: Wed Nov 12 10:03:10 2014
New Revision: 274422
URL: https://svnweb.freebsd.org/changeset/base/274422

Log:
  Sync with head @274421.

Modified:
  projects/sendfile/sys/kern/sys_socket.c
  projects/sendfile/sys/sys/sockbuf.h
Directory Properties:
  projects/sendfile/   (props changed)
  projects/sendfile/sys/   (props changed)

Modified: projects/sendfile/sys/kern/sys_socket.c
==============================================================================
--- projects/sendfile/sys/kern/sys_socket.c	Wed Nov 12 09:57:15 2014	(r274421)
+++ projects/sendfile/sys/kern/sys_socket.c	Wed Nov 12 10:03:10 2014	(r274422)
@@ -185,7 +185,11 @@ soo_ioctl(struct file *fp, u_long cmd, v
 
 	case FIONSPACE:
 		/* Unlocked read. */
-		*(int *)data = sbspace(&so->so_snd);
+		if ((so->so_snd.sb_hiwat < sbused(&so->so_snd)) ||
+		    (so->so_snd.sb_mbmax < so->so_snd.sb_mbcnt))
+			*(int *)data = 0;
+		else
+			*(int *)data = sbspace(&so->so_snd);
 		break;
 
 	case FIOSETOWN:

Modified: projects/sendfile/sys/sys/sockbuf.h
==============================================================================
--- projects/sendfile/sys/sys/sockbuf.h	Wed Nov 12 09:57:15 2014	(r274421)
+++ projects/sendfile/sys/sys/sockbuf.h	Wed Nov 12 10:03:10 2014	(r274422)
@@ -177,6 +177,10 @@ void	sbfree(struct sockbuf *, struct mbu
 void	sbmtrim(struct sockbuf *, struct mbuf *, int);
 int	sbready(struct sockbuf *, struct mbuf *, int);
 
+/*
+ * Return how much data is available to be taken out of socket
+ * buffer right now.
+ */
 static inline u_int
 sbavail(struct sockbuf *sb)
 {
@@ -187,6 +191,10 @@ sbavail(struct sockbuf *sb)
 	return (sb->sb_acc);
 }
 
+/*
+ * Return how much data sits there in the socket buffer
+ * It might be that some data is not yet ready to be read.
+ */
 static inline u_int
 sbused(struct sockbuf *sb)
 {



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201411121003.sACA3B3M078934>