Source-Changes-HG archive

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

[src/trunk]: src/lib/libc/stdlib When converting the locking path of mutex+co...



details:   https://anonhg.NetBSD.org/src/rev/84d01ff10d11
branches:  trunk
changeset: 747996:84d01ff10d11
user:      pooka <pooka%NetBSD.org@localhost>
date:      Thu Oct 08 16:33:45 2009 +0000

description:
When converting the locking path of mutex+counter to a real recursive
mutex, it's a good idea to convert the unlock path too so that the
recursive mutex gets released as many times as it was locked.
Fixes pthread + cxa deadlock.

diffstat:

 lib/libc/stdlib/atexit.c |  8 +++-----
 1 files changed, 3 insertions(+), 5 deletions(-)

diffs (34 lines):

diff -r c98677297347 -r 84d01ff10d11 lib/libc/stdlib/atexit.c
--- a/lib/libc/stdlib/atexit.c  Thu Oct 08 16:19:59 2009 +0000
+++ b/lib/libc/stdlib/atexit.c  Thu Oct 08 16:33:45 2009 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: atexit.c,v 1.23 2008/04/28 20:23:00 martin Exp $       */
+/*     $NetBSD: atexit.c,v 1.24 2009/10/08 16:33:45 pooka Exp $        */
 
 /*-
  * Copyright (c) 2003 The NetBSD Foundation, Inc.
@@ -31,7 +31,7 @@
 
 #include <sys/cdefs.h>
 #if defined(LIBC_SCCS) && !defined(lint)
-__RCSID("$NetBSD: atexit.c,v 1.23 2008/04/28 20:23:00 martin Exp $");
+__RCSID("$NetBSD: atexit.c,v 1.24 2009/10/08 16:33:45 pooka Exp $");
 #endif /* LIBC_SCCS and not lint */
 
 #include "reentrant.h"
@@ -219,14 +219,12 @@
                } else
                        prevp = &ah->ah_next;
        }
-
        call_depth--;
+       mutex_unlock(&atexit_mutex);
 
        if (call_depth > 0)
                return;
 
-       mutex_unlock(&atexit_mutex);
-
        /*
         * Now free any dead handlers.  Do this even if we're about to
         * exit, in case a leak-detecting malloc is being used.



Home | Main Index | Thread Index | Old Index