Frank Cusack <fcusack@fcusack.com> wrote:
I need to add a thread local variable to rlm_otp.
I'm very, very, very, leery of adding thread-specific code to modules. It usually makes things much more complicated.
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.
You could try using a connection pool, like LDAP & SQL. On initialization, open one connection. When the module is called, it looks for a free connection, and if none exists, creates one. As a larger problem, though, multiple modules need those kinds of pools, which means that the code should be abstracted into the server core. Alan DeKok.