From 2dafac3976b1e65dc6e1fe9aee59191d4cd19af1 Mon Sep 17 00:00:00 2001 From: Ed Maste Date: Tue, 30 Jun 2009 13:38:49 +0000 Subject: [PATCH] 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. NetBSD revisions: sys_socket.c r1.41, 1.42 filio.h r1.9 Obtained from: NetBSD Approved by: re (kensmith) --- sys/kern/sys_socket.c | 8 ++++++++ sys/sys/filio.h | 1 + 2 files changed, 9 insertions(+) diff --git a/sys/kern/sys_socket.c b/sys/kern/sys_socket.c index ecfb4adca6d3..c29ecc6445f6 100644 --- a/sys/kern/sys_socket.c +++ b/sys/kern/sys_socket.c @@ -174,6 +174,14 @@ soo_ioctl(struct file *fp, u_long cmd, void *data, struct ucred *active_cred, *(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; diff --git a/sys/sys/filio.h b/sys/sys/filio.h index 68e7852a4ceb..1710ba45e6c5 100644 --- a/sys/sys/filio.h +++ b/sys/sys/filio.h @@ -56,6 +56,7 @@ struct fiodgname_arg { }; #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 */