Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/lib/libpuffs Only add a write filter for sockets. It is not ...
details: https://anonhg.NetBSD.org/src/rev/70f028d54893
branches: trunk
changeset: 353493:70f028d54893
user: christos <christos%NetBSD.org@localhost>
date: Tue May 09 21:15:30 2017 +0000
description:
Only add a write filter for sockets. It is not supported for vnodes, or
for 1/2 closed fifos (which we both have now).
diffstat:
lib/libpuffs/framebuf.c | 28 +++++++++++++++++++---------
1 files changed, 19 insertions(+), 9 deletions(-)
diffs (58 lines):
diff -r ca44b8eaddf4 -r 70f028d54893 lib/libpuffs/framebuf.c
--- a/lib/libpuffs/framebuf.c Tue May 09 11:17:07 2017 +0000
+++ b/lib/libpuffs/framebuf.c Tue May 09 21:15:30 2017 +0000
@@ -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 @@
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 @@
pu->pu_nevs = nevs;
return 0;
+out:
+ free(fio);
+ return -1;
}
int
Home |
Main Index |
Thread Index |
Old Index