char bound;
char locked;
int failed_conns;
+ int uses;
#ifdef HAVE_PTHREAD_H
pthread_mutex_t mutex;
#endif
char *server;
int port;
int timelimit;
+ int max_uses;
int net_timeout;
int timeout;
int debug;
/* allow server unlimited time for search (server-side limit) */
{"timelimit", PW_TYPE_INTEGER,
offsetof(ldap_instance,timelimit), NULL, "20"},
+ {"max_uses", PW_TYPE_INTEGER,
+ offsetof(ldap_instance,max_uses), NULL, "0"},
/*
* TLS configuration The first few are here for backwards
}
/* found an unused connection */
*ret = &conns[i];
+ conns[i].uses++;
conns[i].locked = 1;
DEBUG(" [%s] ldap_get_conn: Got Id: %d",
inst->xlat_name, i);
LDAP_CONN *conns = inst->conns;
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){
+ ldap_unbind_s(inst->conns[i].ld);
+ }
+ conns[i].bound = 0;
+ conns[i].uses = 0;
+ }
conns[i].locked = 0;
pthread_mutex_unlock(&(conns[i].mutex));
}