Threads and modules

Matthew Newton mcn4 at
Mon Mar 23 22:40:55 CET 2015


I've been working on the belief that each separate thread in
FreeRADIUS has a separate instantiation of each module, e.g. a new
thread calls mod_instantiate at startup and mod_detach at finish.
Therefore an instantiation of the module is all within one thread.

I'm now thinking about this further, and believe I'm wrong...?

Reason - mschap code: I'm grabbing winbind context in
mod_instantiate (assuming that is in one thread), using the
context in mod_authenticate, then freeing it in mod_detach. That
runs fine for a while (all testing was good...) then exhibits
problems that I was seeing with a non-threaded library. As I know
the library is now thread-safe because of the use of context, I'm
guessing that the module instantiation isn't separated per thread?

If two threads use the same context at the same time (e.g. are
both running with the same module instantiation simultaneously)
then obviously Bad Things are going to happen.

If this is the case then I guess I'll need to add a connection
pool to make sure the contexts aren't shared... nothing major, but
will explain what I'm seeing after running under load for ~20



Matthew Newton, Ph.D. <mcn4 at>

Systems Specialist, Infrastructure Services,
I.T. Services, University of Leicester, Leicester LE1 7RH, United Kingdom

For IT help contact helpdesk extn. 2253, <ithelp at>

More information about the Freeradius-Devel mailing list