rlm_perl multiple processes/threads behavior

Nick Rogers ncrogers at gmail.com
Thu Sep 18 21:22:23 CEST 2014

On Wed, Sep 17, 2014 at 11:25 PM, Iliya Peregoudov <iperegudov at cboss.ru>

> rlm_perl had never spawn perl processes. rlm_perl embeds perl into the
> radiusd process space, so no inter-process communication is needed to call
> perl functions.
> rlm_perl in freeradius 1.1 uses pool of interpreters. radiusd thread take
> first unused interpreter from pool when rlm_perl is entered and put the
> interpreter back to the pool when rlm_perl is leaved.
> rlm_perl in freeradius 2.1 or higher uses interpreter per thread model.
> When the thread enters the rlm_perl for first time the interpreter is
> allocated and tied to the thread.
> Perl interpreter allocation is only used when perl library is compiled
> with USE_ITHREADS. If no USE_ITHREADS, then module is marked as thread
> unsafe when built. freeradius core ensures not to call rlm_perl instance in
> multiple threads simultaneously and rlm_perl instance uses single
> interpreter.
> If you want single rlm_perl instance to be called simultaneously from
> different thread you need perl built with USE_ITHREADS.
> However you can always call multiple rlm_perl instances simultaneously.
> Define multiple perl instances with same script, and call them from
> load-balance group:
> module pl1 {
>   module = ${confdir}/pl.pl
> }
> module pl2 {
>   module = ${confdir}/pl.pl
> }
> module pl3 {
>   module = ${confdir}/pl.pl
> }
> module pl4 {
>   module = ${confdir}/pl.pl
> }

I'm having trouble getting the above syntax to work. I ended up trying out
something like...

modules {
        perl perl1 {
                module = ${confdir}/perlscript
        perl perl2 {
                module = ${confdir}/perlscript2

accounting {
    load-balance {

Both modules are initialized, but as far as I can tell only one perl
interpreter is being used, using the second script/module perl2. The load
balancing works, in that module perl1 and perl2 are called, but it seems
like the two modules are using the same interpreter/script, where the
last-defined perl module wins.

When I shutdown the server, I get strange messages indicating that the
second script was loaded on top of the first one in the same interpreter.

Attempt to free non-existent shared string 'is_ERROR' during global

Is this because I do not have multiplicity compiled? Or should I be able to
have two unique instances of rlm_perl module with separate interpreters
that do not conflict?
Any suggestions? I'm using 2.2.0


> authorize {
>   load-balance {
>     pl1 # 25% of requests go here
>     pl2
>     pl3
>     pl4
>   }
> }
> On 16.09.2014 22:20, Nick Rogers wrote:
>> Hello,
>> I am hoping someone can clarify some questions I have about how rlm_perl
>> should behave in FreeRADIUS 2.2.5 with respect to multiple instances and
>> freeradius threads. I know there has been some discussion and
>> changes/fixes to this behavior over the years, and I've been using
>> rlm_perl successfully for nearly the last decade. Previously rlm_perl
>> had its own "thread" pool, where multiple instances of the perl process
>> would run simultaneously. Now I understand that rlm_perl uses the same
>> freeradius thread management that everything else does.
>> My problem is that my freeradius rlm_perl installation no longer spawns
>> multiple instances of the perl process, effectively causing my server to
>> be single threaded, which has begun to cause performance issues at some
>> of my larger sites with increased load.
>> I do not have perl with multiplicity or ithreads compiled, as this
>> causes issues with other perl applications running on the same server.
>> My question is, is there a way to support multiple instances of the
>> rlm_perl interpreter without having ithreads or multiplicity compiled
>> with perl?
>> Is there a way for freeradius to simply launch a perl process for every
>> freeradius server thread, instead of all threads relying on the same
>> rlm_perl process? I am not interested in using perl threads or having
>> multiple perl interpreters within the same perl process. I would really
>> appreciate some clarification if this is possible or not.
>> Thanks!
>> -Nick
> -
> List info/subscribe/unsubscribe? See http://www.freeradius.org/
> list/users.html
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.freeradius.org/pipermail/freeradius-users/attachments/20140918/29c0acd5/attachment-0001.html>

More information about the Freeradius-Users mailing list