Creating a timer within a module

Alan DeKok aland at
Mon May 8 20:15:51 CEST 2017

On May 8, 2017, at 2:06 PM, Alejandro Pérez Méndez <alex at> wrote:
> I'm trying to extend the functionality of the trust router client which is implemented in the trustrouter.c file (within the rlm_realm module) by providing basic re-keying capabilities.
> The intention is to create some sort of timer that calls the TIDC library periodically (e.g. every 10 minutes) and refresh the REALM structure (with the TLS keys). So far, this only happens when there is traffic associated to that REALM once they keys have expired. Now, for that periodical call, I need to create some sort of timer that calls me back when the time has expired and let me invoke the TIDC library to update the realm.
> Since I don't want re-inventing the wheel here, is there any recommended way of doing so? I could create a thread, but since you're using some sort of thread pool, I don't want to do anything out of control here which can lead to race conditions while writing to the realm list.

  You should create a thread in the modules initialization routine.  Then, call radius_event_list_corral() to get the main server event list.

  That thread can do updates.

  You will need to be sure that memory accesses are thread-safe.  How to do that... is not simple.  I've made some changes in realms.c, but I don't think they're finished.

  In the end, v3 isn't designed to have dynamic realm updates.  And fixing it will be almost impossible at this stage.

  Alan DeKok.

More information about the Freeradius-Devel mailing list