diff options
Diffstat (limited to 'src/lib')
-rw-r--r-- | src/lib/libc/stdlib/atexit.c | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/src/lib/libc/stdlib/atexit.c b/src/lib/libc/stdlib/atexit.c index 34f76bb7d3..6532b382ea 100644 --- a/src/lib/libc/stdlib/atexit.c +++ b/src/lib/libc/stdlib/atexit.c | |||
@@ -1,4 +1,4 @@ | |||
1 | /* $OpenBSD: atexit.c,v 1.19 2014/07/10 21:14:22 tedu Exp $ */ | 1 | /* $OpenBSD: atexit.c,v 1.20 2014/07/11 09:51:37 kettenis Exp $ */ |
2 | /* | 2 | /* |
3 | * Copyright (c) 2002 Daniel Hartmeier | 3 | * Copyright (c) 2002 Daniel Hartmeier |
4 | * All rights reserved. | 4 | * All rights reserved. |
@@ -116,6 +116,7 @@ __cxa_finalize(void *dso) | |||
116 | int n, pgsize = getpagesize(); | 116 | int n, pgsize = getpagesize(); |
117 | static int call_depth; | 117 | static int call_depth; |
118 | 118 | ||
119 | _ATEXIT_LOCK(); | ||
119 | call_depth++; | 120 | call_depth++; |
120 | 121 | ||
121 | restart: | 122 | restart: |
@@ -136,7 +137,9 @@ restart: | |||
136 | p->fns[n].fn_ptr = NULL; | 137 | p->fns[n].fn_ptr = NULL; |
137 | mprotect(p, pgsize, PROT_READ); | 138 | mprotect(p, pgsize, PROT_READ); |
138 | } | 139 | } |
140 | _ATEXIT_UNLOCK(); | ||
139 | (*fn.fn_ptr)(fn.fn_arg); | 141 | (*fn.fn_ptr)(fn.fn_arg); |
142 | _ATEXIT_LOCK(); | ||
140 | if (restartloop) | 143 | if (restartloop) |
141 | goto restart; | 144 | goto restart; |
142 | } | 145 | } |
@@ -157,6 +160,7 @@ restart: | |||
157 | } | 160 | } |
158 | __atexit = NULL; | 161 | __atexit = NULL; |
159 | } | 162 | } |
163 | _ATEXIT_UNLOCK(); | ||
160 | } | 164 | } |
161 | 165 | ||
162 | /* | 166 | /* |