summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJeremy Allison <jra@samba.org>2011-08-20 09:37:04 -0700
committerJeremy Allison <jra@samba.org>2011-08-20 20:09:37 +0200
commite25345a7a68e93626066d83185ed1944f6bdd044 (patch)
treec57a9516c433dea15f32cae14589b143dfb131be
parent6c3779c80bd2d657a88fb030e16dee10dca45f36 (diff)
downloadsamba-e25345a7a68e93626066d83185ed1944f6bdd044.tar.gz
samba-e25345a7a68e93626066d83185ed1944f6bdd044.tar.bz2
samba-e25345a7a68e93626066d83185ed1944f6bdd044.zip
Ensure we never wait past absolute entime to do a get_cached_ldap_connect().
Autobuild-User: Jeremy Allison <jra@samba.org> Autobuild-Date: Sat Aug 20 20:09:37 CEST 2011 on sn-devel-104
-rw-r--r--source3/lib/smbldap.c23
1 files changed, 15 insertions, 8 deletions
diff --git a/source3/lib/smbldap.c b/source3/lib/smbldap.c
index bdf54fc008..b333f3063d 100644
--- a/source3/lib/smbldap.c
+++ b/source3/lib/smbldap.c
@@ -1407,16 +1407,23 @@ static void get_ldap_errs(struct smbldap_state *ldap_state, char **pp_ld_error,
LDAP_OPT_ERROR_STRING, pp_ld_error);
}
-static int get_cached_ldap_connect(struct smbldap_state *ldap_state)
+static int get_cached_ldap_connect(struct smbldap_state *ldap_state, time_t abs_endtime)
{
int attempts = 0;
while (1) {
int rc;
+ time_t now;
- rc = smbldap_open(ldap_state);
+ now = time_mono(NULL);
+ ldap_state->last_use = now;
+
+ if (abs_endtime && now > abs_endtime) {
+ smbldap_close(ldap_state);
+ return LDAP_TIMEOUT;
+ }
- ldap_state->last_use = time_mono(NULL);
+ rc = smbldap_open(ldap_state);
if (rc == LDAP_SUCCESS) {
return LDAP_SUCCESS;
@@ -1511,7 +1518,7 @@ static int smbldap_search_ext(struct smbldap_state *ldap_state,
char *ld_error = NULL;
int ld_errno;
- rc = get_cached_ldap_connect(ldap_state);
+ rc = get_cached_ldap_connect(ldap_state, abs_endtime);
if (rc != LDAP_SUCCESS) {
break;
}
@@ -1665,7 +1672,7 @@ int smbldap_modify(struct smbldap_state *ldap_state, const char *dn, LDAPMod *at
char *ld_error = NULL;
int ld_errno;
- rc = get_cached_ldap_connect(ldap_state);
+ rc = get_cached_ldap_connect(ldap_state, abs_endtime);
if (rc != LDAP_SUCCESS) {
break;
}
@@ -1715,7 +1722,7 @@ int smbldap_add(struct smbldap_state *ldap_state, const char *dn, LDAPMod *attrs
char *ld_error = NULL;
int ld_errno;
- rc = get_cached_ldap_connect(ldap_state);
+ rc = get_cached_ldap_connect(ldap_state, abs_endtime);
if (rc != LDAP_SUCCESS) {
break;
}
@@ -1765,7 +1772,7 @@ int smbldap_delete(struct smbldap_state *ldap_state, const char *dn)
char *ld_error = NULL;
int ld_errno;
- rc = get_cached_ldap_connect(ldap_state);
+ rc = get_cached_ldap_connect(ldap_state, abs_endtime);
if (rc != LDAP_SUCCESS) {
break;
}
@@ -1811,7 +1818,7 @@ int smbldap_extended_operation(struct smbldap_state *ldap_state,
char *ld_error = NULL;
int ld_errno;
- rc = get_cached_ldap_connect(ldap_state);
+ rc = get_cached_ldap_connect(ldap_state, abs_endtime);
if (rc != LDAP_SUCCESS) {
break;
}