This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
annotate the mutex use of atfork_lock and atfork_unlock
authorJarkko Hietaniemi <jhi@iki.fi>
Thu, 5 Nov 2015 23:57:58 +0000 (18:57 -0500)
committerJarkko Hietaniemi <jhi@iki.fi>
Mon, 23 Nov 2015 11:55:12 +0000 (06:55 -0500)
util.c:2729:1: warning: mutex 'PL_perlio_mutex' is still held at the end of function [-Wthread-safety-analysis]
}

util.c:2729:1: warning: mutex 'PL_op_mutex' is still held at the end of function [-Wthread-safety-analysis]
}

util.c:2739:5: warning: releasing mutex 'PL_perlio_mutex' that was not held [-Wthread-safety-analysis]
    MUTEX_UNLOCK(&PL_perlio_mutex);

util.c:2744:5: warning: releasing mutex 'PL_op_mutex' that was not held [-Wthread-safety-analysis]
    OP_REFCNT_UNLOCK;

util.c

diff --git a/util.c b/util.c
index 4d66fe5..aeec4c0 100644 (file)
--- a/util.c
+++ b/util.c
@@ -2714,6 +2714,15 @@ Perl_my_popen(pTHX_ const char *cmd, const char *mode)
 /* this is called in parent before the fork() */
 void
 Perl_atfork_lock(void)
+#if defined(USE_ITHREADS)
+#  ifdef USE_PERLIO
+  PERL_TSA_ACQUIRE(PL_perlio_mutex)
+#  endif
+#  ifdef MYMALLOC
+  PERL_TSA_ACQUIRE(PL_malloc_mutex)
+#  endif
+  PERL_TSA_ACQUIRE(PL_op_mutex)
+#endif
 {
 #if defined(USE_ITHREADS)
     dVAR;
@@ -2731,6 +2740,15 @@ Perl_atfork_lock(void)
 /* this is called in both parent and child after the fork() */
 void
 Perl_atfork_unlock(void)
+#if defined(USE_ITHREADS)
+#  ifdef USE_PERLIO
+  PERL_TSA_RELEASE(PL_perlio_mutex)
+#  endif
+#  ifdef MYMALLOC
+  PERL_TSA_RELEASE(PL_malloc_mutex)
+#  endif
+  PERL_TSA_RELEASE(PL_op_mutex)
+#endif
 {
 #if defined(USE_ITHREADS)
     dVAR;