Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 12 Sep 2005 19:54:32 GMT
From:      Robert Watson <rwatson@FreeBSD.org>
To:        Perforce Change Reviews <perforce@freebsd.org>
Subject:   PERFORCE change 83496 for review
Message-ID:  <200509121954.j8CJsWEO074790@repoman.freebsd.org>

next in thread | raw e-mail | index | archive | help
http://perforce.freebsd.org/chv.cgi?CH=83496

Change 83496 by rwatson@rwatson_zoo on 2005/09/12 19:54:04

	Add a new "not supported" filter set for kqueue on fifos: when
	read is requested on a write-only descriptor, or write is requested
	on a read-only descriptor, permit registration (no error), but
	never raise the event.  That way, kqueue behavior matches poll and
	select.

Affected files ...

.. //depot/projects/netsmp/src/sys/fs/fifofs/fifo_vnops.c#7 edit

Differences ...

==== //depot/projects/netsmp/src/sys/fs/fifofs/fifo_vnops.c#7 (text+ko) ====

@@ -94,11 +94,15 @@
 static int	filt_fiforead(struct knote *kn, long hint);
 static void	filt_fifowdetach(struct knote *kn);
 static int	filt_fifowrite(struct knote *kn, long hint);
+static void	filt_fifodetach_notsup(struct knote *kn);
+static int	filt_fifo_notsup(struct knote *kn, long hint);
 
 static struct filterops fiforead_filtops =
 	{ 1, NULL, filt_fifordetach, filt_fiforead };
 static struct filterops fifowrite_filtops =
 	{ 1, NULL, filt_fifowdetach, filt_fifowrite };
+static struct filterops fifo_notsup_filtops =
+	{ 1, NULL, filt_fifodetach_notsup, filt_fifo_notsup };
 
 struct vop_vector fifo_specops = {
 	.vop_default =		&default_vnodeops,
@@ -435,6 +439,19 @@
 	return (result);
 }
 
+static void
+filt_fifodetach_notsup(struct knote *kn)
+{
+
+}
+
+static int
+filt_fifo_notsup(struct knote *kn, long hint)
+{
+
+	return (0);
+}
+
 /*
  * Device close routine
  */
@@ -580,6 +597,22 @@
 	struct sockbuf *sb;
 
 	fi = fp->f_data;
+
+	/*
+	 * If a filter is requested that is not supported by this file
+	 * descriptor, don't return an error, but also don't ever generate an
+	 * event.
+	 */
+	if ((kn->kn_filter == EVFILT_READ) && !(fp->f_flag & FREAD)) {
+		kn->kn_fop = &fifo_notsup_filtops;
+		return (0);
+	}
+
+	if ((kn->kn_filter == EVFILT_WRITE) && !(fp->f_flag & FWRITE)) {
+		kn->kn_fop = &fifo_notsup_filtops;
+		return (0);
+	}
+
 	switch (kn->kn_filter) {
 	case EVFILT_READ:
 		kn->kn_fop = &fiforead_filtops;
@@ -685,4 +718,3 @@
 	error = sosend(fip->fi_writesock, NULL, uio, 0, NULL, sflags, td);
 	return (error);
 }
-



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