LDAP timeouts during failure conditions

Alan DeKok aland at deployingradius.com
Sat Jul 2 10:14:23 CEST 2011


Phil Mayers wrote:
> Do you have any pointers how to get started on this? Off the top of my
> head it seems we'd need something like the code below; a struct to hold
> module-supplied connection create/keepalive/delete functions, some code
> in the server core to set and re-set "last used" times and call a
> keepalive function, and delete

  Pretty much that, yes.

> typedef struct {
>   int alive;
>   void *conn;
>   /* mutex stuff */
> } fr_pool_conn;

  Add more stats to that: last used, # of uses, etc.

> typedef struct {
>   int pool_min;
>   int pool_max;
>   int pool_idle;
>   fr_pool_conn *conns;
> 
>   void* (*conn_create)(void *arg);
>   int (*conn_keepalive)(void *conn, void *arg);
>   int (*conn_delete)(void *conn, void *arg);
> 
>   void *arg;

  "ctx" instead of "arg", it's a bit clearer.

> } fr_conn_pool;
>
> ...and then something like:
...
> int ldap_init(...) {
> 
>  inst->ldap_pool = fr_pool_create(
>     5, /* min connection */,

  Nah, pass the CONF_SECTION to the pool creation code.  It will take
care of parsing the min/max connections stuff.  That also allows you to
add new configuration without changing existing callers!

> int perform_search() {
> 
>   ldap_instance *inst = ...;
>   /* timeout argument - 0 == pool - seconds or microseconds? */
>   LDAP *conn = fr_pool_get(&inst->ldap_pool, 0);
>   /* stuff
>   fr_pool_release(&inst->ldap_pool, conn);

  Pretty much, yes.

  Hmm... if we really wanted to go nuts, the code in src/main/threads.c
does a lot of this already.  It could be hacked to use a connection
pool. too.

  Alan DeKok.



More information about the Freeradius-Devel mailing list