From: Florian Forster Date: Wed, 30 Apr 2008 08:59:19 +0000 (+0200) Subject: Merge branch 'collectd-4.2' into collectd-4.3 X-Git-Tag: collectd-4.4.0~4^2~2 X-Git-Url: https://git.tokkee.org/?a=commitdiff_plain;h=4d36d5826a3853ccd62195daf3b831d942850f1a;p=collectd.git Merge branch 'collectd-4.2' into collectd-4.3 Conflicts: configure.in src/perl.c --- 4d36d5826a3853ccd62195daf3b831d942850f1a diff --cc src/perl.c index 96e85622,68d6ddcf..877bc008 --- a/src/perl.c +++ b/src/perl.c @@@ -1357,35 -817,18 +1357,40 @@@ static int init_pi (int argc, char **ar } #endif /* COLLECT_DEBUG */ + if (0 != pthread_key_create (&perl_thr_key, c_ithread_destructor)) { + log_err ("init_pi: pthread_key_create failed"); + + /* this must not happen - cowardly giving up if it does */ + exit (1); + } + + #ifdef __FreeBSD__ + /* On FreeBSD, PERL_SYS_INIT3 expands to some expression which + * triggers a "value computed is not used" warning by gcc. */ + (void) + #endif PERL_SYS_INIT3 (&argc, &argv, &environ); - if (NULL == (perl = perl_alloc ())) { - log_err ("module_register: Not enough memory."); + perl_threads = (c_ithread_list_t *)smalloc (sizeof (c_ithread_list_t)); + memset (perl_threads, 0, sizeof (c_ithread_list_t)); + + pthread_mutex_init (&perl_threads->mutex, NULL); + /* 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); + + perl_threads->head = c_ithread_create (NULL); + perl_threads->tail = perl_threads->head; + + if (NULL == (perl_threads->head->interp = perl_alloc ())) { + log_err ("init_pi: Not enough memory."); exit (3); } - perl_construct (perl); + + aTHX = perl_threads->head->interp; + pthread_mutex_unlock (&perl_threads->mutex); + + perl_construct (aTHX); PL_exit_flags |= PERL_EXIT_DESTRUCT_END;