Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/lib/libpthread Store allocated lwpctl state in the thread ac...
details: https://anonhg.NetBSD.org/src/rev/ad87e8709c5a
branches: trunk
changeset: 779018:ad87e8709c5a
user: enami <enami%NetBSD.org@localhost>
date: Thu Apr 26 00:21:44 2012 +0000
description:
Store allocated lwpctl state in the thread actually forked,
which is the only thread lives in the child process.
The problem originally reported here:
https://bugs.ruby-lang.org/issues/6341
diffstat:
lib/libpthread/pthread.c | 11 ++++-------
1 files changed, 4 insertions(+), 7 deletions(-)
diffs (50 lines):
diff -r 7c88d8e59ced -r ad87e8709c5a lib/libpthread/pthread.c
--- a/lib/libpthread/pthread.c Wed Apr 25 22:35:00 2012 +0000
+++ b/lib/libpthread/pthread.c Thu Apr 26 00:21:44 2012 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: pthread.c,v 1.133 2012/03/22 20:01:18 drochner Exp $ */
+/* $NetBSD: pthread.c,v 1.134 2012/04/26 00:21:44 enami Exp $ */
/*-
* Copyright (c) 2001, 2002, 2003, 2006, 2007, 2008 The NetBSD Foundation, Inc.
@@ -30,7 +30,7 @@
*/
#include <sys/cdefs.h>
-__RCSID("$NetBSD: pthread.c,v 1.133 2012/03/22 20:01:18 drochner Exp $");
+__RCSID("$NetBSD: pthread.c,v 1.134 2012/04/26 00:21:44 enami Exp $");
#define __EXPOSE_STACK 1
@@ -84,7 +84,6 @@
static pthread_attr_t pthread_default_attr;
static lwpctl_t pthread__dummy_lwpctl = { .lc_curcpu = LWPCTL_CPU_NONE };
-static pthread_t pthread__first;
enum {
DIAGASSERT_ABORT = 1<<0,
@@ -229,7 +228,6 @@
}
/* Tell libc that we're here and it should role-play accordingly. */
- pthread__first = first;
pthread_atfork(NULL, NULL, pthread__fork_callback);
__isthreaded = 1;
}
@@ -237,13 +235,12 @@
static void
pthread__fork_callback(void)
{
- struct __pthread_st *self;
+ struct __pthread_st *self = pthread__self();
/* lwpctl state is not copied across fork. */
- if (_lwp_ctl(LWPCTL_FEATURE_CURCPU, &pthread__first->pt_lwpctl)) {
+ if (_lwp_ctl(LWPCTL_FEATURE_CURCPU, &self->pt_lwpctl)) {
err(1, "_lwp_ctl");
}
- self = pthread__self();
self->pt_lid = _lwp_self();
}
Home |
Main Index |
Thread Index |
Old Index