Module Name:    src
Committed By:   christos
Date:           Tue May  9 21:15:30 UTC 2017

Modified Files:
        src/lib/libpuffs: framebuf.c

Log Message:
Only add a write filter for sockets. It is not supported for vnodes, or
for 1/2 closed fifos (which we both have now).


To generate a diff of this commit:
cvs rdiff -u -r1.32 -r1.33 src/lib/libpuffs/framebuf.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/lib/libpuffs/framebuf.c
diff -u src/lib/libpuffs/framebuf.c:1.32 src/lib/libpuffs/framebuf.c:1.33
--- src/lib/libpuffs/framebuf.c:1.32	Mon Jun 25 18:32:47 2012
+++ src/lib/libpuffs/framebuf.c	Tue May  9 17:15:30 2017
@@ -1,4 +1,4 @@
-/*	$NetBSD: framebuf.c,v 1.32 2012/06/25 22:32:47 abs Exp $	*/
+/*	$NetBSD: framebuf.c,v 1.33 2017/05/09 21:15:30 christos Exp $	*/
 
 /*
  * Copyright (c) 2007  Antti Kantee.  All Rights Reserved.
@@ -35,7 +35,7 @@
 
 #include <sys/cdefs.h>
 #if !defined(lint)
-__RCSID("$NetBSD: framebuf.c,v 1.32 2012/06/25 22:32:47 abs Exp $");
+__RCSID("$NetBSD: framebuf.c,v 1.33 2017/05/09 21:15:30 christos Exp $");
 #endif /* !lint */
 
 #include <sys/types.h>
@@ -807,15 +807,22 @@ puffs__framev_addfd_ctrl(struct puffs_us
 		readenable = EV_DISABLE;
 
 	if (pu->pu_state & PU_INLOOP) {
-		EV_SET(&kev[0], fd, EVFILT_READ,
+		struct stat st;
+		size_t nf = 0;
+
+		if (fstat(fd, &st) == -1)
+			goto out;
+		EV_SET(&kev[nf], fd, EVFILT_READ,
 		    EV_ADD|readenable, 0, 0, (intptr_t)fio);
-		EV_SET(&kev[1], fd, EVFILT_WRITE,
-		    EV_ADD|EV_DISABLE, 0, 0, (intptr_t)fio);
-		rv = kevent(pu->pu_kq, kev, 2, NULL, 0, NULL);
-		if (rv == -1) {
-			free(fio);
-			return -1;
+		nf++;
+		if (S_ISSOCK(st.st_mode)) {
+			EV_SET(&kev[nf], fd, EVFILT_WRITE,
+			    EV_ADD|EV_DISABLE, 0, 0, (intptr_t)fio);
+			nf++;
 		}
+		rv = kevent(pu->pu_kq, kev, nf, NULL, 0, NULL);
+		if (rv == -1)
+			goto out;
 	}
 	if (what & PUFFS_FBIO_READ)
 		fio->stat |= FIO_ENABLE_R;
@@ -826,6 +833,9 @@ puffs__framev_addfd_ctrl(struct puffs_us
 	pu->pu_nevs = nevs;
 
 	return 0;
+out:
+	free(fio);
+	return -1;
 }
 
 int

Reply via email to