perl_func_def_t *func;
} perl_call_env_t;
+typedef struct {
+ pthread_mutex_t mutex;
+} rlm_perl_mutable_t;
+
/*
* Define a structure for our module configuration.
*
PerlInterpreter *perl;
bool perl_parsed;
HV *rad_perlconf_hv; //!< holds "config" items (perl %RAD_PERLCONF hash).
+ rlm_perl_mutable_t *mutable;
} rlm_perl_t;
PERL_SET_CONTEXT(inst->perl);
+ /*
+ * Ensure only one thread is cloning an interpreter at a time
+ * Whilst the documentation of perl_clone() does not say anything
+ * about this, seg faults have been seen if multiple threads clone
+ * the same inst->perl at the same time.
+ */
+ pthread_mutex_lock(&inst->mutable->mutex);
interp = perl_clone(inst->perl, clone_flags);
+ pthread_mutex_unlock(&inst->mutable->mutex);
{
dTHXa(interp); /* Sets the current thread's interpreter */
}
PL_endav = end_AV;
+ inst->mutable = talloc(NULL, rlm_perl_mutable_t);
+ pthread_mutex_init(&inst->mutable->mutex, NULL);
+
return 0;
}
}
rlm_perl_interp_free(inst->perl);
+ talloc_free(inst->mutable);
return ret;
}