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
@@@ -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);