]> git.ipfire.org Git - thirdparty/freeradius-server.git/commitdiff
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:24:52 +0000 (16:24 +0100)
raddb/modules/ldap
src/modules/rlm_ldap/rlm_ldap.c

index c47fe09b04018851222e7d7b8c7ee4f2dd80f4bc..d13892634e4a8458c942ce170f59f98521dce500 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 8a4ac0822eef363b4bfb6e5ac0eb2c5fd871b010..a01c4d6c77aadfafe96397f2d2a9a545cc745934 100644 (file)
@@ -250,6 +250,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"},
 
@@ -404,9 +405,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;