Source-Changes-HG archive

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

[src/trunk]: src/tests/rump/rumpkern Make sure stressclient worker threads co...



details:   https://anonhg.NetBSD.org/src/rev/14b37e5db909
branches:  trunk
changeset: 760675:14b37e5db909
user:      pooka <pooka%NetBSD.org@localhost>
date:      Mon Jan 10 19:51:37 2011 +0000

description:
Make sure stressclient worker threads complete their operation
instead of hanging.

diffstat:

 tests/rump/rumpkern/h_client/h_stresscli.c |  16 +++++++++++-----
 tests/rump/rumpkern/t_sp.sh                |   4 ++--
 2 files changed, 13 insertions(+), 7 deletions(-)

diffs (77 lines):

diff -r 470f77f25c32 -r 14b37e5db909 tests/rump/rumpkern/h_client/h_stresscli.c
--- a/tests/rump/rumpkern/h_client/h_stresscli.c        Mon Jan 10 19:49:43 2011 +0000
+++ b/tests/rump/rumpkern/h_client/h_stresscli.c        Mon Jan 10 19:51:37 2011 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: h_stresscli.c,v 1.3 2011/01/10 14:05:03 pooka Exp $    */
+/*     $NetBSD: h_stresscli.c,v 1.4 2011/01/10 19:51:37 pooka Exp $    */
 
 #include <sys/types.h>
 #include <sys/atomic.h>
@@ -17,12 +17,13 @@
 
 static unsigned int syscalls;
 static pid_t mypid;
+static volatile sig_atomic_t doquit;
 
 static void
 signaali(int sig)
 {
 
-       _exit(0);
+       doquit = 1;
 }
 
 static const int hostnamemib[] = { CTL_KERN, KERN_HOSTNAME };
@@ -35,7 +36,7 @@
        char buf[256];
        size_t blen;
 
-       for (;;) {
+       while (!doquit) {
                pid_t pidi;
                blen = sizeof(buf);
                if (rump_sys___sysctl(hostnamemib, __arraycount(hostnamemib),
@@ -63,7 +64,7 @@
 int
 main(int argc, char *argv[])
 {
-       pthread_t pt;
+       pthread_t pt[NTHR-1];
        pid_t clis[NCLI];
        pid_t apid;
        int ncli = 0;
@@ -94,10 +95,15 @@
                                signal(SIGUSR1, signaali);
 
                                for (j = 0; j < NTHR-1; j++)
-                                       if (pthread_create(&pt, NULL,
+                                       if (pthread_create(&pt[j], NULL,
                                            client, NULL) != 0)
                                                err(1, "pthread create");
                                client(NULL);
+                               for (j = 0; j < NTHR-1; j++)
+                                       pthread_join(pt[j], NULL);
+                               membar_consumer();
+                               fprintf(stderr, "done %d\n", syscalls);
+                               exit(0);
                                /* NOTREACHED */
                        default:
                                ncli++;
diff -r 470f77f25c32 -r 14b37e5db909 tests/rump/rumpkern/t_sp.sh
--- a/tests/rump/rumpkern/t_sp.sh       Mon Jan 10 19:49:43 2011 +0000
+++ b/tests/rump/rumpkern/t_sp.sh       Mon Jan 10 19:51:37 2011 +0000
@@ -1,4 +1,4 @@
-#      $NetBSD: t_sp.sh,v 1.5 2011/01/06 07:00:28 pooka Exp $
+#      $NetBSD: t_sp.sh,v 1.6 2011/01/10 19:51:37 pooka Exp $
 #
 # Copyright (c) 2010 The NetBSD Foundation, Inc.
 # All rights reserved.
@@ -60,7 +60,7 @@
 
        export RUMP_SERVER=unix://commsock
        atf_check -s exit:0 rump_server ${RUMP_SERVER}
-       atf_check -s exit:0 $(atf_get_srcdir)/h_client/h_stresscli ${1}
+       atf_check -s exit:0 -e ignore $(atf_get_srcdir)/h_client/h_stresscli $1
 }
 
 fork()



Home | Main Index | Thread Index | Old Index