Fix and document max_uses
authorArran Cudbard-Bell <a.cudbardb@freeradius.org>
Wed, 22 Aug 2012 15:24:52 +0000 (16:24 +0100)
committerArran Cudbard-Bell <a.cudbardb@freeradius.org>
Wed, 22 Aug 2012 15:51:07 +0000 (16:51 +0100)
raddb/mods-available/ldap
src/modules/rlm_ldap/rlm_ldap.c

index 550d375..e57c987 100644 (file)
@@ -42,6 +42,12 @@ ldap {
        #  every authentication request.
        ldap_connections_number = 5
 
+       #  How many times the connection can be used before
+       #  being re-established. This is useful for things
+       #  like load balancers, which may exhibit sticky
+       #  behaviour without it. (0) is unlimited.
+       max_uses = 0
+
        #  Port to connect on, defaults to 389. Setting this to
        #  636 will enable LDAPS if start_tls (see below) is not
        #  able to be used.
index ccf653c..2b2e095 100644 (file)
@@ -249,6 +249,7 @@ static const CONF_PARSER module_config[] = {
        /* allow server unlimited time for search (server-side limit) */
        {"timelimit", PW_TYPE_INTEGER,
         offsetof(ldap_instance,timelimit), NULL, "20"},
+       /* how many times the connection can be used before being re-established */     
        {"max_uses", PW_TYPE_INTEGER,
         offsetof(ldap_instance,max_uses), NULL, "0"},
 
@@ -399,9 +400,11 @@ static inline void ldap_release_conn(int i, ldap_instance *inst)
 
        DEBUG("  [%s] ldap_release_conn: Release Id: %d", inst->xlat_name, i);
        if ((inst->max_uses > 0) && (conns[i].uses >= inst->max_uses)) {
-               if (inst->conns[i].ld){
+               if (conns[i].ld){
                        DEBUG("  [%s] ldap_release_conn: Hit max usage limit, closing Id: %d", inst->xlat_name, i);
-                       ldap_unbind_s(inst->conns[i].ld);
+                       ldap_unbind_s(conns[i].ld);
+                       
+                       conns[i].ld = NULL      
                }
                conns[i].bound = 0;
                conns[i].uses = 0;