Code

Merge pull request #1710 from rpv-tomsk/perl-plugin-fixes
authorSebastian Harl <sh@tokkee.org>
Mon, 30 May 2016 18:54:42 +0000 (20:54 +0200)
committerSebastian Harl <sh@tokkee.org>
Mon, 30 May 2016 18:54:42 +0000 (20:54 +0200)
perl plugin: Synchronize access to thread information.

Cf. #1706

1  2 
src/perl.c

diff --cc src/perl.c
index 92a162bd1acb4a1a347f0a324e1d35605e3da64c,5e03e3a5e8d5d625925160493941c1cabcccf582..f90761a561d20bc72b9988c9b7ca0abf81d85516
@@@ -2249,10 -2317,12 +2311,12 @@@ static int init_pi (int argc, char **ar
  #endif
        PERL_SYS_INIT3 (&argc, &argv, &environ);
  
 -      perl_threads = (c_ithread_list_t *)smalloc (sizeof (c_ithread_list_t));
 +      perl_threads = smalloc (sizeof (*perl_threads));
        memset (perl_threads, 0, sizeof (c_ithread_list_t));
  
-       pthread_mutex_init (&perl_threads->mutex, NULL);
+       pthread_mutexattr_init(&perl_threads->mutexattr);
+       pthread_mutexattr_settype(&perl_threads->mutexattr, PTHREAD_MUTEX_RECURSIVE);
+       pthread_mutex_init (&perl_threads->mutex, &perl_threads->mutexattr);
        /* locking the mutex should not be necessary at this point
         * but let's just do it for the sake of completeness */
        pthread_mutex_lock (&perl_threads->mutex);