svn commit: r197422 - in stable/7/sys: . contrib/pf kern sys

Ed Maste emaste at FreeBSD.org
Tue Sep 22 23:11:24 UTC 2009


Author: emaste
Date: Tue Sep 22 23:11:23 2009
New Revision: 197422
URL: http://svn.freebsd.org/changeset/base/197422

Log:
  MFC r195134, r195135, r195191
  
  r195134, r195134:
    Add a complement to FIONREAD, called FIONWRITE, which returns the
    number of bytes not yet properly disposed of.  Implement it for
    all sockets.
  
  r195191:
    Add FIONSPACE from NetBSD.  FIONSPACE is provided so that programs
    may easily determine how much space is left in the send queue;
    they do not need to know the send queue size.

Modified:
  stable/7/sys/   (props changed)
  stable/7/sys/contrib/pf/   (props changed)
  stable/7/sys/kern/sys_socket.c
  stable/7/sys/sys/filio.h

Modified: stable/7/sys/kern/sys_socket.c
==============================================================================
--- stable/7/sys/kern/sys_socket.c	Tue Sep 22 22:23:52 2009	(r197421)
+++ stable/7/sys/kern/sys_socket.c	Tue Sep 22 23:11:23 2009	(r197422)
@@ -161,6 +161,19 @@ soo_ioctl(struct file *fp, u_long cmd, v
 		*(int *)data = so->so_rcv.sb_cc;
 		break;
 
+	case FIONWRITE:
+		/* Unlocked read. */
+		*(int *)data = so->so_snd.sb_cc;
+		break;
+
+	case FIONSPACE:
+		if ((so->so_snd.sb_hiwat < so->so_snd.sb_cc) ||
+		    (so->so_snd.sb_mbmax < so->so_snd.sb_mbcnt))
+			*(int *)data = 0;
+		else
+			*(int *)data = sbspace(&so->so_snd);
+		break;
+
 	case FIOSETOWN:
 		error = fsetown(*(int *)data, &so->so_sigio);
 		break;

Modified: stable/7/sys/sys/filio.h
==============================================================================
--- stable/7/sys/sys/filio.h	Tue Sep 22 22:23:52 2009	(r197421)
+++ stable/7/sys/sys/filio.h	Tue Sep 22 23:11:23 2009	(r197422)
@@ -55,6 +55,8 @@ struct fiodgname_arg {
 	void	*buf;
 };
 #define	FIODGNAME	_IOW('f', 120, struct fiodgname_arg) /* get dev. name */
+#define	FIONWRITE	_IOR('f', 119, int)	/* get # bytes (yet) to write */
+#define	FIONSPACE	_IOR('f', 118, int)	/* get space in send queue */
 /* Handle lseek SEEK_DATA and SEEK_HOLE for holey file knowledge. */
 #define	FIOSEEKDATA	_IOWR('f', 97, off_t)	/* SEEK_DATA */
 #define	FIOSEEKHOLE	_IOWR('f', 98, off_t)	/* SEEK_HOLE */


More information about the svn-src-all mailing list