[haiku-commits] haiku: hrev51332 - in src: system/kernel/fs tests/system/kernel

  • From: philippe.houdoin@xxxxxxxxx
  • To: haiku-commits@xxxxxxxxxxxxx
  • Date: Tue, 1 Aug 2017 18:52:05 +0200 (CEST)

hrev51332 adds 3 changesets to branch 'master'
old head: 4c774d6f944be93b65aa704568f5042935b75b43
new head: 12b5c184b2af00deb9dce9347ffdeadfddd2d72c
overview: 
http://cgit.haiku-os.org/haiku/log/?qt=range&q=12b5c184b2af+%5E4c774d6f944b

----------------------------------------------------------------------------

216574f371c8: fifo: fix #7859

17f88a29db36: Fix x86_64 build

12b5c184b2af: kernel: add fifo polling test from #7859

                           [ Philippe Houdoin <philippe.houdoin@xxxxxxxxx> ]

----------------------------------------------------------------------------

4 files changed, 44 insertions(+), 11 deletions(-)
src/system/kernel/fs/fifo.cpp                 | 17 ++++++------
src/tests/system/kernel/Jamfile               |  2 ++
src/tests/system/kernel/fifo_poll_test.cpp    | 32 +++++++++++++++++++++++
src/tests/system/kernel/select_close_test.cpp |  4 +--

############################################################################

Commit:      216574f371c89dad626afdcd34186822292c7568
URL:         http://cgit.haiku-os.org/haiku/commit/?id=216574f371c8
Author:      Philippe Houdoin <philippe.houdoin@xxxxxxxxx>
Date:        Wed Jul 26 18:15:11 2017 UTC

Ticket:      https://dev.haiku-os.org/ticket/7859

fifo: fix #7859

----------------------------------------------------------------------------

diff --git a/src/system/kernel/fs/fifo.cpp b/src/system/kernel/fs/fifo.cpp
index e7e9f2c..65c1b02 100644
--- a/src/system/kernel/fs/fifo.cpp
+++ b/src/system/kernel/fs/fifo.cpp
@@ -615,7 +615,7 @@ Inode::NotifyEndClosed(bool writer)
                                request->Notify();
 
                        if (fReadSelectSyncPool)
-                               notify_select_event_pool(fReadSelectSyncPool, 
B_SELECT_READ);
+                               notify_select_event_pool(fReadSelectSyncPool, 
B_SELECT_DISCONNECTED);
                }
        } else {
                // Last reader is gone. Wake up all writers.
@@ -623,7 +623,7 @@ Inode::NotifyEndClosed(bool writer)
 
                if (fWriteSelectSyncPool) {
                        notify_select_event_pool(fWriteSelectSyncPool, 
B_SELECT_WRITE);
-                       notify_select_event_pool(fWriteSelectSyncPool, 
B_SELECT_ERROR);
+                       notify_select_event_pool(fWriteSelectSyncPool, 
B_SELECT_DISCONNECTED);
                }
        }
 }
@@ -710,16 +710,15 @@ Inode::Select(uint8 event, selectsync* sync, int openMode)
 
        // signal right away, if the condition holds already
        if (writer) {
-               if ((event == B_SELECT_WRITE
-                               && (fBuffer.Writable() > 0 || fReaderCount == 
0))
-                       || (event == B_SELECT_ERROR && fReaderCount == 0)) {
+               if (event == B_SELECT_WRITE && fBuffer.Writable() > 0)
                        return notify_select_event(sync, event);
-               }
+               if (fReaderCount == 0)
+                       return notify_select_event(sync, B_SELECT_DISCONNECTED);
        } else {
-               if (event == B_SELECT_READ
-                               && (fBuffer.Readable() > 0 || fWriterCount == 
0)) {
+               if (event == B_SELECT_READ && fBuffer.Readable() > 0)
                        return notify_select_event(sync, event);
-               }
+               if (fWriterCount == 0)
+                       return notify_select_event(sync, B_SELECT_DISCONNECTED);
        }
 
        return B_OK;

############################################################################

Commit:      17f88a29db367dac570f063dd51e466efaec40fb
URL:         http://cgit.haiku-os.org/haiku/commit/?id=17f88a29db36
Author:      Philippe Houdoin <philippe.houdoin@xxxxxxxxx>
Date:        Tue Aug  1 18:32:29 2017 UTC

Fix x86_64 build

----------------------------------------------------------------------------

diff --git a/src/tests/system/kernel/select_close_test.cpp 
b/src/tests/system/kernel/select_close_test.cpp
index 422a507..2663d98 100644
--- a/src/tests/system/kernel/select_close_test.cpp
+++ b/src/tests/system/kernel/select_close_test.cpp
@@ -11,7 +11,7 @@
 static status_t
 close_fd(void* data)
 {
-       int fd = int(data);
+       int fd = *((int*)data);
        snooze(1000000);
        close(fd);
        fprintf(stderr, "fd %d closed\n", fd);
@@ -25,7 +25,7 @@ main()
        int fd = dup(0);
 
        thread_id thread = spawn_thread(close_fd, "close fd", B_NORMAL_PRIORITY,
-               (void*)fd);
+               &fd);
        resume_thread(thread);
 
        fd_set readSet;

############################################################################

Revision:    hrev51332
Commit:      12b5c184b2af00deb9dce9347ffdeadfddd2d72c
URL:         http://cgit.haiku-os.org/haiku/commit/?id=12b5c184b2af
Author:      Philippe Houdoin <philippe.houdoin@xxxxxxxxx>
Date:        Tue Aug  1 18:50:36 2017 UTC

Ticket:      https://dev.haiku-os.org/ticket/7859

kernel: add fifo polling test from #7859

----------------------------------------------------------------------------

diff --git a/src/tests/system/kernel/Jamfile b/src/tests/system/kernel/Jamfile
index ee1602a..7c5b751 100644
--- a/src/tests/system/kernel/Jamfile
+++ b/src/tests/system/kernel/Jamfile
@@ -11,6 +11,8 @@ SimpleTest fibo_load_image : fibo_load_image.cpp ;
 SimpleTest fibo_fork : fibo_fork.cpp ;
 SimpleTest fibo_exec : fibo_exec.cpp ;
 
+SimpleTest fifo_poll_test : fifo_poll_test.cpp ;
+
 SimpleTest live_query :
        live_query.cpp
        : be
diff --git a/src/tests/system/kernel/fifo_poll_test.cpp 
b/src/tests/system/kernel/fifo_poll_test.cpp
new file mode 100644
index 0000000..4606e65
--- /dev/null
+++ b/src/tests/system/kernel/fifo_poll_test.cpp
@@ -0,0 +1,32 @@
+#include <stdio.h>
+#include <poll.h>
+
+int main() {
+       FILE* f = popen("/bin/bash -c 'for i in 1 2 3; do { echo $i; sleep 1; 
}; done'", "r");
+       printf("f=%p\n", f);
+       int fd = fileno(f);
+       printf("fd=%d\n", fd);
+
+       struct pollfd pfd;
+       pfd.fd = fd;
+       pfd.events = POLLIN | POLLRDBAND;
+
+       char buffer[80];
+
+       while (1) {
+               int rv = poll(&pfd, 1, 500);
+               printf("rv=%d\n", rv);
+               if (rv == 0)
+                       continue;
+               if (rv < 0)
+                       break;
+               printf("events=%08x revents=%08x\n", pfd.events, pfd.revents);
+               if ((pfd.events & pfd.revents) == 0)
+                       break;
+
+               fgets(buffer, 79, f);
+               printf("output: %s", buffer);
+       }
+
+       return 0;
+}


Other related posts: