diff options
author | Andrew Bartlett <abartlet@samba.org> | 2012-05-18 22:01:14 +1000 |
---|---|---|
committer | Karolin Seeger <kseeger@samba.org> | 2012-06-30 13:44:06 +0200 |
commit | 179a71f78748c52aca73280cc35e2580d7f75416 (patch) | |
tree | 281be4d46c5e27e183b83ea78d8de643ab0de3e9 | |
parent | d63a8bd52709835ea063b8f0230f973540965397 (diff) | |
download | samba-179a71f78748c52aca73280cc35e2580d7f75416.tar.gz |
s3-libads: Use a reducing page size to try and cope with a slow LDAP server
If we cannot get 1000 users downloaded in 15seconds, try with 500, 250
and then 125 users at a time.
Andrew Bartlett
(cherry picked from commit 8572ce0e5ff17bfe0df2823078119be9182a0378)
-rw-r--r-- | source3/include/ads.h | 1 | ||||
-rw-r--r-- | source3/libads/ads_struct.c | 4 | ||||
-rw-r--r-- | source3/libads/ldap.c | 4 | ||||
-rw-r--r-- | source3/libads/ldap_utils.c | 7 |
4 files changed, 14 insertions, 2 deletions
diff --git a/source3/include/ads.h b/source3/include/ads.h index 62d51ce03b5..ff3dc123b48 100644 --- a/source3/include/ads.h +++ b/source3/include/ads.h @@ -108,6 +108,7 @@ typedef struct ads_struct { time_t current_time; char *schema_path; char *config_path; + int ldap_page_size; } config; /* info about the current LDAP connection */ diff --git a/source3/libads/ads_struct.c b/source3/libads/ads_struct.c index aef35ad822e..2d9ea17faac 100644 --- a/source3/libads/ads_struct.c +++ b/source3/libads/ads_struct.c @@ -148,6 +148,10 @@ ADS_STRUCT *ads_init(const char *realm, ads->auth.flags = wrap_flags; + /* Start with a page size of 1000 when the connection is new, + * we will drop it by half we get a timeout. */ + ads->config.ldap_page_size = 1000; + return ads; } diff --git a/source3/libads/ldap.c b/source3/libads/ldap.c index f18ded15d9f..99ec2e46dc6 100644 --- a/source3/libads/ldap.c +++ b/source3/libads/ldap.c @@ -924,11 +924,11 @@ static ADS_STATUS ads_do_paged_search_args(ADS_STRUCT *ads, cookie_be = ber_alloc_t(LBER_USE_DER); if (*cookie) { - ber_printf(cookie_be, "{iO}", (ber_int_t) 1000, *cookie); + ber_printf(cookie_be, "{iO}", (ber_int_t) ads->config.ldap_page_size, *cookie); ber_bvfree(*cookie); /* don't need it from last time */ *cookie = NULL; } else { - ber_printf(cookie_be, "{io}", (ber_int_t) 1000, "", 0); + ber_printf(cookie_be, "{io}", (ber_int_t) ads->config.ldap_page_size, "", 0); } ber_flatten(cookie_be, &cookie_bv); PagedResults.ldctl_oid = CONST_DISCARD(char *, ADS_PAGE_CTL_OID); diff --git a/source3/libads/ldap_utils.c b/source3/libads/ldap_utils.c index 871449a81af..dee3c03a216 100644 --- a/source3/libads/ldap_utils.c +++ b/source3/libads/ldap_utils.c @@ -68,6 +68,13 @@ static ADS_STATUS ads_do_search_retry_internal(ADS_STRUCT *ads, const char *bind while (--count) { + if (NT_STATUS_EQUAL(ads_ntstatus(status), NT_STATUS_IO_TIMEOUT) && ads->config.ldap_page_size >= 250) { + int new_page_size = (ads->config.ldap_page_size / 2); + DEBUG(1, ("Reducing LDAP page size from %d to %d due to IO_TIMEOUT\n", + ads->config.ldap_page_size, new_page_size)); + ads->config.ldap_page_size = new_page_size; + } + if (*res) ads_msgfree(ads, *res); *res = NULL; |