Source-Changes-HG archive

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

[src/trunk]: src/tests/lib/librumpclient If pthread_create fails, report the ...



details:   https://anonhg.NetBSD.org/src/rev/dd897799e35e
branches:  trunk
changeset: 819179:dd897799e35e
user:      dholland <dholland%NetBSD.org@localhost>
date:      Mon Nov 21 06:17:20 2016 +0000

description:
If pthread_create fails, report the error instead of discarding it.

diffstat:

 tests/lib/librumpclient/h_execthr.c |  22 +++++++++++++---------
 1 files changed, 13 insertions(+), 9 deletions(-)

diffs (37 lines):

diff -r 8adb91abfc96 -r dd897799e35e tests/lib/librumpclient/h_execthr.c
--- a/tests/lib/librumpclient/h_execthr.c       Mon Nov 21 04:10:05 2016 +0000
+++ b/tests/lib/librumpclient/h_execthr.c       Mon Nov 21 06:17:20 2016 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: h_execthr.c,v 1.3 2014/08/13 00:03:00 pooka Exp $      */
+/*     $NetBSD: h_execthr.c,v 1.4 2016/11/21 06:17:20 dholland Exp $   */
 
 /*
  * Copyright (c) 2011 The NetBSD Foundation, Inc.
@@ -151,15 +151,19 @@
        if (rump_sys_fcntl(p1[1], F_SETFD, FD_CLOEXEC) == -1)
                err(1, "cloexec");
 
-       for (i = 0; i < NTHR; i++)
-               if (pthread_create(&pt, NULL,
-                   wrk, (void *)(uintptr_t)p1[0]) != 0)
-                       errx(1, "pthread_create 1 %d", i);
+       for (i = 0; i < NTHR; i++) {
+               errno = pthread_create(&pt, NULL,
+                   wrk, (void *)(uintptr_t)p1[0]);
+               if (errno != 0)
+                       err(1, "pthread_create 1 %d", i);
+       }
 
-       for (i = 0; i < NTHR; i++)
-               if (pthread_create(&pt, NULL,
-                   wrk, (void *)(uintptr_t)p2[0]) != 0)
-                       errx(1, "pthread_create 2 %d", i);
+       for (i = 0; i < NTHR; i++) {
+               errno = pthread_create(&pt, NULL,
+                   wrk, (void *)(uintptr_t)p2[0]);
+               if (errno != 0)
+                       err(1, "pthread_create 2 %d", i);
+       }
 
        /* wait for all the threads to be enjoying themselves */
        for (;;) {



Home | Main Index | Thread Index | Old Index