Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/tests/fs/puffs poll the putter fd instead of doing a blockin...



details:   https://anonhg.NetBSD.org/src/rev/31a78b9f9d66
branches:  trunk
changeset: 757386:31a78b9f9d66
user:      pooka <pooka%NetBSD.org@localhost>
date:      Fri Aug 27 12:42:21 2010 +0000

description:
poll the putter fd instead of doing a blocking read.  Long story
short:  we don't have to wait for the fs syncer to run for the
close to succeed.

diffstat:

 tests/fs/puffs/t_fuzz.c |  14 ++++++++++++--
 1 files changed, 12 insertions(+), 2 deletions(-)

diffs (53 lines):

diff -r 0676cdf3d823 -r 31a78b9f9d66 tests/fs/puffs/t_fuzz.c
--- a/tests/fs/puffs/t_fuzz.c   Fri Aug 27 11:02:55 2010 +0000
+++ b/tests/fs/puffs/t_fuzz.c   Fri Aug 27 12:42:21 2010 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: t_fuzz.c,v 1.3 2010/08/16 10:46:20 pooka Exp $ */
+/*     $NetBSD: t_fuzz.c,v 1.4 2010/08/27 12:42:21 pooka Exp $ */
 
 /*-
  * Copyright (c) 2010 The NetBSD Foundation, Inc.
@@ -38,6 +38,7 @@
 
 #include <sys/types.h>
 #include <sys/mount.h>
+#include <sys/poll.h>
 
 #include <assert.h>
 #include <atf-c.h>
@@ -167,6 +168,7 @@
 {
        char buf[PUFFS_MSG_MAXSIZE];
        struct puffs_req *preq = (void *)buf;
+       struct pollfd pfd;
        ssize_t n;
 
        pthread_mutex_lock(&damtx);
@@ -176,6 +178,13 @@
 
                while (dafd != -1) {
                        pthread_mutex_unlock(&damtx);
+                       pfd.fd = dafd;
+                       pfd.events = POLLIN;
+                       pfd.revents = 0;
+                       if (rump_sys_poll(&pfd, 1, 10) == 0) {
+                               pthread_mutex_lock(&damtx);
+                               continue;
+                       }
                        n = rump_sys_read(dafd, buf, sizeof(buf));
                        if (n <= 0) {
                                pthread_mutex_lock(&damtx);
@@ -204,11 +213,12 @@
        srandom(seed);
        printf("test seeded RNG with %lu\n", seed);
 
+       rump_init();
+
        pthread_mutex_init(&damtx, NULL);
        pthread_cond_init(&dacv, NULL);
        pthread_create(&pt, NULL, respondthread, NULL);
 
-       rump_init();
        ATF_REQUIRE(rump_sys_mkdir("/mnt", 0777) == 0);
 
        for (i = 0; i < ITERATIONS; i++) {



Home | Main Index | Thread Index | Old Index