rlm_perl and threads

Sander Eerdekens sander.eerdekens at uzleuven.be
Mon Nov 5 16:06:33 CET 2012


The old wiki used to contain more information on this.
I'm currently in the process of making our rlm_perl module multithreaded as well.

Some pointers:
perl -V | grep -i multipl
...
    useithreads=define, usemultiplicity=define
  Compile-time options: HAS_TIMES MULTIPLICITY PERLIO_LAYERS

check your multiplicity here. Multiplicity causes one perl process to be started, with multiple perl interpreters inside.

Add a CLONE function to your perl script (yes, all in caps).
The CLONE function is run every time a new perl interpreter is started. What happens is all existing variables are copied to the new interpreter when a new thread is started.
In this function you can adjust values that should be unique for each thread (like database handlers).

The number of threads are controlled trough the max_servers and max/min spare servers  in your radiusd.conf

Threading is not done in debug mode (-X), start your freeradius in normal mode to test multithreading.

AFAIK the above information is correct and recent.

Kind regards

Sander Eerdekens
Informatiesystemen
Systeembeheer & Ondersteuning

sander at uzleuven.be
UZ Leuven | campus Gasthuisberg | Herestraat 49 | B - 3000 Leuven | www.uzleuven.be




------------------------------

Message: 5
Date: Mon, 05 Nov 2012 14:01:56 +0000
From: Phil Mayers <p.mayers at imperial.ac.uk>
To: freeradius-users at lists.freeradius.org
Subject: Re: rlm_perl and threads
Message-ID: <5097C6D4.9070904 at imperial.ac.uk>
Content-Type: text/plain; charset=ISO-8859-1; format=flowed

On 05/11/12 13:36, Edgar Fu? wrote:
>> Yes. Likely, even.
> Thanks. So will these then be two distinct Perl interpreters or two instances
> of the same Perl interpreter? From the Perl script's point of view, what will
> the two instances share?
> Can you hint me to any documentation covering this?

I'm not aware of any docs. You might need to refer to the source.

In particular, the USE_ITHREADS #define seems to control how the perl 
interpreter is created/allocated/used. I'm not familiar enough with perl 
to understand the code, personally. See here:

https://github.com/FreeRADIUS/freeradius-server/blob/master/src/modules/rlm_perl/rlm_perl.c#L254

...and the rest of that file.



More information about the Freeradius-Users mailing list