I need to add a thread local variable to rlm_otp. It's a per-thread fd which connects to another program running locally. rlm_otp makes requests of it and it returns results. The semantics of that program does not guarantee sequencing of results unless each request thread has its own connection. That is, if I have a global fd, the response received by one thread may not be to the correct request: t1 t2 get_state(foo) get_state(bar) -> write(foo) -> write(bar) -> read() -> read() -> bar -> foo The other program may return bar first, and even if it returned results in the order received, because both threads are blocked in read(), either might pick up the result for the other. An fd per thread fixes this. It also fixes the problem that writes() might interleave (atomic writes are only guaranteed in certain cases which won't be met here), but that is just icing for the cake. The problem, though, is that on thread exit no cleanup is done. I want to add two functions to threads.c: register_constructor() and register_destructor(). When a module is instantiated, it can call these to register functions to be called on thread creation and destruction. (rlm_otp will register a destructor which closes the fd.) It's fairly trivial, but it touches the "core" of freeradius, and it affects thread behavior, so I wanted to be sure there were no objections before adding it. -frank