Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/lib/librumpuser If pthread_create() fails with EAGAIN, try a...
details: https://anonhg.NetBSD.org/src/rev/01f688de9601
branches: trunk
changeset: 790164:01f688de9601
user: pooka <pooka%NetBSD.org@localhost>
date: Mon Sep 23 10:35:20 2013 +0000
description:
If pthread_create() fails with EAGAIN, try a few more times with short
sleeps in between. If it helps, good. If it doesn't, oh well, at
least we tried. pthread_create() returning EAGAIN has been observed in
real life at least on Linux (buildrump.sh issue #40)
diffstat:
lib/librumpuser/rumpuser_pth.c | 16 ++++++++++++----
1 files changed, 12 insertions(+), 4 deletions(-)
diffs (44 lines):
diff -r 3a47cfb221eb -r 01f688de9601 lib/librumpuser/rumpuser_pth.c
--- a/lib/librumpuser/rumpuser_pth.c Mon Sep 23 08:39:28 2013 +0000
+++ b/lib/librumpuser/rumpuser_pth.c Mon Sep 23 10:35:20 2013 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: rumpuser_pth.c,v 1.30 2013/05/15 14:52:49 pooka Exp $ */
+/* $NetBSD: rumpuser_pth.c,v 1.31 2013/09/23 10:35:20 pooka Exp $ */
/*
* Copyright (c) 2007-2010 Antti Kantee. All Rights Reserved.
@@ -28,7 +28,7 @@
#include "rumpuser_port.h"
#if !defined(lint)
-__RCSID("$NetBSD: rumpuser_pth.c,v 1.30 2013/05/15 14:52:49 pooka Exp $");
+__RCSID("$NetBSD: rumpuser_pth.c,v 1.31 2013/09/23 10:35:20 pooka Exp $");
#endif /* !lint */
#include <sys/queue.h>
@@ -54,7 +54,7 @@
pthread_t ptid;
pthread_t *ptidp;
pthread_attr_t pattr;
- int rv;
+ int rv, i;
if ((rv = pthread_attr_init(&pattr)) != 0)
return rv;
@@ -67,7 +67,15 @@
pthread_attr_setdetachstate(&pattr, PTHREAD_CREATE_DETACHED);
}
- rv = pthread_create(ptidp, &pattr, f, arg);
+ for (i = 0; i < 10; i++) {
+ const struct timespec ts = {0, 10*1000*1000};
+
+ rv = pthread_create(ptidp, &pattr, f, arg);
+ if (rv != EAGAIN)
+ break;
+ nanosleep(&ts, NULL);
+ }
+
#if defined(__NetBSD__)
if (rv == 0 && thrname)
pthread_setname_np(ptid, thrname, NULL);
Home |
Main Index |
Thread Index |
Old Index