svn commit: r312277 - in head/sys: kern sys

Hiren Panchasara hiren at FreeBSD.org
Mon Jan 16 08:25:35 UTC 2017


Author: hiren
Date: Mon Jan 16 08:25:33 2017
New Revision: 312277
URL: https://svnweb.freebsd.org/changeset/base/312277

Log:
  Add kevent EVFILT_EMPTY for notification when a client has received all data
  i.e. everything outstanding has been acked.
  
  Reviewed by:	bz, gnn (previous version)
  MFC after:	3 days
  Sponsored by:	Limelight Networks
  Differential Revision:	https://reviews.freebsd.org/D9150

Modified:
  head/sys/kern/kern_event.c
  head/sys/kern/uipc_socket.c
  head/sys/sys/event.h

Modified: head/sys/kern/kern_event.c
==============================================================================
--- head/sys/kern/kern_event.c	Mon Jan 16 07:41:39 2017	(r312276)
+++ head/sys/kern/kern_event.c	Mon Jan 16 08:25:33 2017	(r312277)
@@ -344,6 +344,7 @@ static struct {
 	{ &null_filtops },			/* EVFILT_LIO */
 	{ &user_filtops, 1 },			/* EVFILT_USER */
 	{ &null_filtops },			/* EVFILT_SENDFILE */
+	{ &file_filtops, 1 },                   /* EVFILT_EMPTY */
 };
 
 /*

Modified: head/sys/kern/uipc_socket.c
==============================================================================
--- head/sys/kern/uipc_socket.c	Mon Jan 16 07:41:39 2017	(r312276)
+++ head/sys/kern/uipc_socket.c	Mon Jan 16 08:25:33 2017	(r312277)
@@ -161,6 +161,7 @@ static void	filt_sowdetach(struct knote 
 static int	filt_sowrite(struct knote *kn, long hint);
 static int	filt_solisten(struct knote *kn, long hint);
 static int inline hhook_run_socket(struct socket *so, void *hctx, int32_t h_id);
+static int	filt_soempty(struct knote *kn, long hint);
 fo_kqfilter_t	soo_kqfilter;
 
 static struct filterops solisten_filtops = {
@@ -178,6 +179,11 @@ static struct filterops sowrite_filtops 
 	.f_detach = filt_sowdetach,
 	.f_event = filt_sowrite,
 };
+static struct filterops soempty_filtops = {
+	.f_isfd = 1,
+	.f_detach = filt_sowdetach,
+	.f_event = filt_soempty,
+};
 
 so_gen_t	so_gencnt;	/* generation count for sockets */
 
@@ -3083,6 +3089,10 @@ soo_kqfilter(struct file *fp, struct kno
 		kn->kn_fop = &sowrite_filtops;
 		sb = &so->so_snd;
 		break;
+	case EVFILT_EMPTY:
+		kn->kn_fop = &soempty_filtops;
+		sb = &so->so_snd;
+		break;
 	default:
 		return (EINVAL);
 	}
@@ -3344,6 +3354,21 @@ filt_sowrite(struct knote *kn, long hint
 		return (kn->kn_data >= so->so_snd.sb_lowat);
 }
 
+static int
+filt_soempty(struct knote *kn, long hint)
+{
+	struct socket *so;
+
+	so = kn->kn_fp->f_data;
+	SOCKBUF_LOCK_ASSERT(&so->so_snd);
+	kn->kn_data = sbused(&so->so_snd);
+
+	if (kn->kn_data == 0)
+		return (1);
+	else
+		return (0);
+}
+
 /*ARGSUSED*/
 static int
 filt_solisten(struct knote *kn, long hint)

Modified: head/sys/sys/event.h
==============================================================================
--- head/sys/sys/event.h	Mon Jan 16 07:41:39 2017	(r312276)
+++ head/sys/sys/event.h	Mon Jan 16 08:25:33 2017	(r312277)
@@ -43,7 +43,8 @@
 #define EVFILT_LIO		(-10)	/* attached to lio requests */
 #define EVFILT_USER		(-11)	/* User events */
 #define EVFILT_SENDFILE		(-12)	/* attached to sendfile requests */
-#define EVFILT_SYSCOUNT		12
+#define EVFILT_EMPTY		(-13)	/* empty send socket buf */
+#define EVFILT_SYSCOUNT		13
 
 #define EV_SET(kevp_, a, b, c, d, e, f) do {	\
 	struct kevent *kevp = (kevp_);		\


More information about the svn-src-head mailing list