hrev51811 adds 4 changesets to branch 'master'
old head: 46b328f136c65b3f6fcf65bfff00a58fba84569c
new head: fb6387f2b46230b8ce98d58ef76fc99157ed2bf8
overview:
http://cgit.haiku-os.org/haiku/log/?qt=range&q=fb6387f2b462+%5E46b328f136c6
----------------------------------------------------------------------------
8a38c1fdc2c0: kernel: fd: don't notify output-only select events by default
Output-only events (B_EVENT_ERROR, B_EVENT_DISCONNECTED and
B_EVENT_INVALID, with B_EVENT_INVALID masked out before passing down
events) are used to indicate error, so they should not be notified if
the filesystem does not explicitly provide an fd_select() override.
Bug: 13965
f3b05a74bbff: kernel: devfs: don't notify output-only select events by default
Output-only events (B_EVENT_ERROR, B_EVENT_DISCONNECTED and
B_EVENT_INVALID, with B_EVENT_INVALID masked out before passing down
events) are used to indicate error, so they should not be notified if
the device does not have Select().
Bug: 13965
a9388f6d3915: kernel: vfs: don't notify output-only select events by default
Output-only events (B_EVENT_ERROR, B_EVENT_DISCONNECTED and
B_EVENT_INVALID, with B_EVENT_INVALID masked out before passing down
events) are used to indicate error, so they should not be notified if
the vnode does not have select().
Bug: 13965
fb6387f2b462: kernel: add /dev/null polling test
Bug: 13965
[ Xiang Fan <sfanxiang@xxxxxxxxx> ]
----------------------------------------------------------------------------
5 files changed, 53 insertions(+), 6 deletions(-)
src/system/kernel/device_manager/devfs.cpp | 9 ++++++--
src/system/kernel/fs/fd.cpp | 8 +++++--
src/system/kernel/fs/vfs.cpp | 9 ++++++--
src/tests/system/kernel/Jamfile | 2 ++
src/tests/system/kernel/null_poll_test.cpp | 31 ++++++++++++++++++++++++++
############################################################################
Commit: 8a38c1fdc2c032ae0b5e8e173d63b05c123c642e
URL: http://cgit.haiku-os.org/haiku/commit/?id=8a38c1fdc2c0
Author: Xiang Fan <sfanxiang@xxxxxxxxx>
Date: Sat Jan 20 15:47:51 2018 UTC
Committer: Jérôme Duval <jerome.duval@xxxxxxxxx>
Commit-Date: Mon Feb 26 10:44:22 2018 UTC
kernel: fd: don't notify output-only select events by default
Output-only events (B_EVENT_ERROR, B_EVENT_DISCONNECTED and
B_EVENT_INVALID, with B_EVENT_INVALID masked out before passing down
events) are used to indicate error, so they should not be notified if
the filesystem does not explicitly provide an fd_select() override.
Bug: 13965
----------------------------------------------------------------------------
diff --git a/src/system/kernel/fs/fd.cpp b/src/system/kernel/fs/fd.cpp
index 4e50e906ef..25b85d9ea3 100644
--- a/src/system/kernel/fs/fd.cpp
+++ b/src/system/kernel/fs/fd.cpp
@@ -566,10 +566,14 @@ select_fd(int32 fd, struct select_info* info, bool kernel)
uint16 eventsToSelect = info->selected_events & ~B_EVENT_INVALID;
- if (descriptor->ops->fd_select == NULL && eventsToSelect != 0) {
+ if (descriptor->ops->fd_select == NULL) {
// if the I/O subsystem doesn't support select(), we will
// immediately notify the select call
- return notify_select_events(info, eventsToSelect);
+ eventsToSelect &= ~SELECT_OUTPUT_ONLY_FLAGS;
+ if (eventsToSelect != 0)
+ return notify_select_events(info, eventsToSelect);
+ else
+ return B_OK;
}
// We need the FD to stay open while we're doing this, so no select()/
############################################################################
Commit: f3b05a74bbff88e0d1b7310618f10b6c2f85ea32
URL: http://cgit.haiku-os.org/haiku/commit/?id=f3b05a74bbff
Author: Xiang Fan <sfanxiang@xxxxxxxxx>
Date: Sat Jan 20 16:14:49 2018 UTC
Committer: Jérôme Duval <jerome.duval@xxxxxxxxx>
Commit-Date: Mon Feb 26 10:44:22 2018 UTC
kernel: devfs: don't notify output-only select events by default
Output-only events (B_EVENT_ERROR, B_EVENT_DISCONNECTED and
B_EVENT_INVALID, with B_EVENT_INVALID masked out before passing down
events) are used to indicate error, so they should not be notified if
the device does not have Select().
Bug: 13965
----------------------------------------------------------------------------
diff --git a/src/system/kernel/device_manager/devfs.cpp
b/src/system/kernel/device_manager/devfs.cpp
index c0139f3fe3..4fc5d3102d 100644
--- a/src/system/kernel/device_manager/devfs.cpp
+++ b/src/system/kernel/device_manager/devfs.cpp
@@ -35,6 +35,7 @@
#include <util/AutoLock.h>
#include <vfs.h>
#include <vm/vm.h>
+#include <wait_for_objects.h>
#include "BaseDevice.h"
#include "FileDevice.h"
@@ -1552,8 +1553,12 @@ devfs_select(fs_volume* _volume, fs_vnode* _vnode, void*
_cookie,
return B_NOT_ALLOWED;
// If the device has no select() hook, notify select() now.
- if (!vnode->stream.u.dev.device->HasSelect())
- return notify_select_event((selectsync*)sync, event);
+ if (!vnode->stream.u.dev.device->HasSelect()) {
+ if (!SELECT_TYPE_IS_OUTPUT_ONLY(event))
+ return notify_select_event((selectsync*)sync, event);
+ else
+ return B_OK;
+ }
return vnode->stream.u.dev.device->Select(cookie->device_cookie, event,
(selectsync*)sync);
############################################################################
Commit: a9388f6d391579800fba459ae938aba253555c37
URL: http://cgit.haiku-os.org/haiku/commit/?id=a9388f6d3915
Author: Xiang Fan <sfanxiang@xxxxxxxxx>
Date: Sat Jan 20 16:15:39 2018 UTC
Committer: Jérôme Duval <jerome.duval@xxxxxxxxx>
Commit-Date: Mon Feb 26 10:44:22 2018 UTC
kernel: vfs: don't notify output-only select events by default
Output-only events (B_EVENT_ERROR, B_EVENT_DISCONNECTED and
B_EVENT_INVALID, with B_EVENT_INVALID masked out before passing down
events) are used to indicate error, so they should not be notified if
the vnode does not have select().
Bug: 13965
----------------------------------------------------------------------------
diff --git a/src/system/kernel/fs/vfs.cpp b/src/system/kernel/fs/vfs.cpp
index 8f9ebe3e97..a519af4555 100644
--- a/src/system/kernel/fs/vfs.cpp
+++ b/src/system/kernel/fs/vfs.cpp
@@ -52,6 +52,7 @@
#include <vfs.h>
#include <vm/vm.h>
#include <vm/VMCache.h>
+#include <wait_for_objects.h>
#include "EntryCache.h"
#include "fifo.h"
@@ -5773,8 +5774,12 @@ file_select(struct file_descriptor* descriptor, uint8
event,
struct vnode* vnode = descriptor->u.vnode;
// If the FS has no select() hook, notify select() now.
- if (!HAS_FS_CALL(vnode, select))
- return notify_select_event(sync, event);
+ if (!HAS_FS_CALL(vnode, select)) {
+ if (!SELECT_TYPE_IS_OUTPUT_ONLY(event))
+ return notify_select_event(sync, event);
+ else
+ return B_OK;
+ }
return FS_CALL(vnode, select, descriptor->cookie, event, sync);
}
############################################################################
Revision: hrev51811
Commit: fb6387f2b46230b8ce98d58ef76fc99157ed2bf8
URL: http://cgit.haiku-os.org/haiku/commit/?id=fb6387f2b462
Author: Xiang Fan <sfanxiang@xxxxxxxxx>
Date: Sun Jan 21 10:22:53 2018 UTC
Committer: Jérôme Duval <jerome.duval@xxxxxxxxx>
Commit-Date: Mon Feb 26 10:44:22 2018 UTC
kernel: add /dev/null polling test
Bug: 13965
----------------------------------------------------------------------------
diff --git a/src/tests/system/kernel/Jamfile b/src/tests/system/kernel/Jamfile
index 7c5b7519b0..7698f8ab30 100644
--- a/src/tests/system/kernel/Jamfile
+++ b/src/tests/system/kernel/Jamfile
@@ -51,6 +51,8 @@ SimpleTest port_wakeup_test_9 : port_wakeup_test_9.cpp ;
SimpleTest mmap_resize_test : mmap_resize_test.cpp ;
+SimpleTest null_poll_test : null_poll_test.cpp ;
+
SimpleTest reserved_areas_test : reserved_areas_test.cpp ;
SimpleTest select_check : select_check.cpp ;
diff --git a/src/tests/system/kernel/null_poll_test.cpp
b/src/tests/system/kernel/null_poll_test.cpp
new file mode 100644
index 0000000000..95519f8c62
--- /dev/null
+++ b/src/tests/system/kernel/null_poll_test.cpp
@@ -0,0 +1,31 @@
+/*
+ * Copyright 2018, Xiang Fan, sfanxiang@xxxxxxxxx.
+ * Distributed under the terms of the MIT License.
+ */
+
+#include <stdio.h>
+#include <poll.h>
+
+
+int main()
+{
+ FILE* f = fopen("/dev/null", "w");
+ printf("f=%p\n", f);
+ int fd = fileno(f);
+ printf("fd=%d\n", fd);
+
+ struct pollfd pfd;
+ pfd.fd = fd;
+ pfd.events = POLLOUT;
+ pfd.revents = 0;
+
+ int rv = poll(&pfd, 1, -1);
+ printf("rv=%d\n", rv);
+ if (rv <= 0)
+ return 1;
+ printf("events=%08x revents=%08x\n", pfd.events, pfd.revents);
+ if (pfd.revents != POLLOUT)
+ return 2;
+
+ return 0;
+}