From: Alan T. DeKok Date: Thu, 1 Dec 2011 13:21:03 +0000 (+0100) Subject: Perl clone should be called sequentially, not in parallel. X-Git-Tag: release_3_0_0_beta0~454 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=a97f8cc93a6f282777935e9b8a49c22c3fcc4647;p=thirdparty%2Ffreeradius-server.git Perl clone should be called sequentially, not in parallel. Adding a mutex fixes this. Patch from Eike Dehling --- diff --git a/src/modules/rlm_perl/rlm_perl.c b/src/modules/rlm_perl/rlm_perl.c index ec57e9a77e3..61411c4ca31 100644 --- a/src/modules/rlm_perl/rlm_perl.c +++ b/src/modules/rlm_perl/rlm_perl.c @@ -79,6 +79,8 @@ typedef struct perl_inst { char *perl_flags; PerlInterpreter *perl; pthread_key_t *thread_key; + + pthread_mutex_t clone_mutex; } PERL_INST; /* * A mapping of configuration file names to internal variables. @@ -440,6 +442,8 @@ static int perl_instantiate(CONF_SECTION *conf, void **instance) */ #ifdef USE_ITHREADS + pthread_mutex_init(&inst->clone_mutex, NULL); + inst->thread_key = rad_malloc(sizeof(*inst->thread_key)); memset(inst->thread_key,0,sizeof(*inst->thread_key)); @@ -669,8 +673,10 @@ static int rlmperl_call(void *instance, REQUEST *request, char *function_name) HV *rad_request_proxy_hv; HV *rad_request_proxy_reply_hv; #endif - + #ifdef USE_ITHREADS + pthread_mutex_lock(&inst->clone_mutex); + PerlInterpreter *interp; interp = rlm_perl_clone(inst->perl,inst->thread_key); @@ -678,9 +684,12 @@ static int rlmperl_call(void *instance, REQUEST *request, char *function_name) dTHXa(interp); PERL_SET_CONTEXT(interp); } + + pthread_mutex_unlock(&inst->clone_mutex); #else PERL_SET_CONTEXT(inst->perl); #endif + { dSP; @@ -996,6 +1005,7 @@ static int perl_detach(void *instance) #ifdef USE_ITHREADS rlm_perl_destruct(inst->perl); + pthread_mutex_destroy(&inst->clone_mutex); #else perl_destruct(inst->perl); perl_free(inst->perl);