Skip to content

Commit 2dc676e

Browse files
committed
Don't panic if can't destroy mutex during global destruction
It's going to be destroyed anyway; this just obscures what the real failure might be.
1 parent dcf3fa4 commit 2dc676e

File tree

1 file changed

+19
-12
lines changed

1 file changed

+19
-12
lines changed

thread.h

Lines changed: 19 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -221,13 +221,16 @@
221221
RESTORE_ERRNO; \
222222
} STMT_END
223223

224-
# define MUTEX_DESTROY(m) \
225-
STMT_START { \
226-
int _eC_; \
227-
if ((_eC_ = pthread_mutex_destroy((m)))) { \
228-
Perl_croak_nocontext("panic: MUTEX_DESTROY (%d) [%s:%d]", \
229-
_eC_, __FILE__, __LINE__); \
230-
} \
224+
# define MUTEX_DESTROY(m) \
225+
STMT_START { \
226+
int _eC_; \
227+
if ((_eC_ = pthread_mutex_destroy((m)))) { \
228+
dTHX; \
229+
if (PL_phase != PERL_PHASE_DESTRUCT) { \
230+
Perl_croak_nocontext("panic: MUTEX_DESTROY (%d) [%s:%d]", \
231+
_eC_, __FILE__, __LINE__); \
232+
} \
233+
} \
231234
} STMT_END
232235
#endif /* MUTEX_INIT */
233236

@@ -265,11 +268,15 @@
265268
} STMT_END
266269

267270
# define COND_DESTROY(c) \
268-
STMT_START { \
269-
int _eC_; \
270-
if ((_eC_ = pthread_cond_destroy((c)))) \
271-
Perl_croak_nocontext("panic: COND_DESTROY (%d) [%s:%d]", \
272-
_eC_, __FILE__, __LINE__); \
271+
STMT_START { \
272+
int _eC_; \
273+
if ((_eC_ = pthread_cond_destroy((c)))) { \
274+
dTHX; \
275+
if (PL_phase != PERL_PHASE_DESTRUCT) { \
276+
Perl_croak_nocontext("panic: COND_DESTROY (%d) [%s:%d]", \
277+
_eC_, __FILE__, __LINE__); \
278+
} \
279+
} \
273280
} STMT_END
274281
#endif /* COND_INIT */
275282

0 commit comments

Comments
 (0)