Module Name:    src
Committed By:   pooka
Date:           Thu Oct  8 16:33:45 UTC 2009

Modified Files:
        src/lib/libc/stdlib: atexit.c

Log Message:
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.


To generate a diff of this commit:
cvs rdiff -u -r1.23 -r1.24 src/lib/libc/stdlib/atexit.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/lib/libc/stdlib/atexit.c
diff -u src/lib/libc/stdlib/atexit.c:1.23 src/lib/libc/stdlib/atexit.c:1.24
--- src/lib/libc/stdlib/atexit.c:1.23	Mon Apr 28 20:23:00 2008
+++ src/lib/libc/stdlib/atexit.c	Thu Oct  8 16:33:45 2009
@@ -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.

Reply via email to