|
|
dc8c34 |
From c68a5e0ea82af904ffcdc7a8c7f8dc1f9edb686a Mon Sep 17 00:00:00 2001
|
|
|
dc8c34 |
From: Noriko Hosoi <nhosoi@redhat.com>
|
|
|
dc8c34 |
Date: Tue, 8 Jul 2014 17:40:00 -0700
|
|
|
dc8c34 |
Subject: [PATCH 236/243] Ticket #47824 - paged results control is not working
|
|
|
dc8c34 |
in some cases when we have a subsuffix.
|
|
|
dc8c34 |
|
|
|
dc8c34 |
Bug Description: When a simple paged result search is run against
|
|
|
dc8c34 |
multiple backends, subsuffix backends were not correctly set to the
|
|
|
dc8c34 |
next loop when crossing the backend boundary.
|
|
|
dc8c34 |
|
|
|
dc8c34 |
Fix Description: This patch changes the logic to detect the page
|
|
|
dc8c34 |
search finished and set the next backend correctly to the paged-
|
|
|
dc8c34 |
results handle. Also, when reusing the paged result handle in
|
|
|
dc8c34 |
pagedresults_parse_control_value, increment the refcnt.
|
|
|
dc8c34 |
|
|
|
dc8c34 |
https://fedorahosted.org/389/ticket/47824
|
|
|
dc8c34 |
|
|
|
dc8c34 |
Reviewed by mreynolds@redhat.com (Thank you, Mark!!)
|
|
|
dc8c34 |
(cherry picked from commit b116d7e2a7a8e7443be93ecb84efee1364b6ba86)
|
|
|
dc8c34 |
(cherry picked from commit 0bc9016541b7033916bc9ca6636f447a95d33c36)
|
|
|
dc8c34 |
(cherry picked from commit 96741952eff493cca968914346bab898a064a986)
|
|
|
dc8c34 |
---
|
|
|
dc8c34 |
ldap/servers/slapd/opshared.c | 17 ++++++++++-------
|
|
|
dc8c34 |
ldap/servers/slapd/pagedresults.c | 5 +++++
|
|
|
dc8c34 |
2 files changed, 15 insertions(+), 7 deletions(-)
|
|
|
dc8c34 |
|
|
|
dc8c34 |
diff --git a/ldap/servers/slapd/opshared.c b/ldap/servers/slapd/opshared.c
|
|
|
dc8c34 |
index 1689283..65fcea6 100644
|
|
|
dc8c34 |
--- a/ldap/servers/slapd/opshared.c
|
|
|
dc8c34 |
+++ b/ldap/servers/slapd/opshared.c
|
|
|
dc8c34 |
@@ -510,7 +510,6 @@ op_shared_search (Slapi_PBlock *pb, int send_result)
|
|
|
dc8c34 |
err_code = slapi_mapping_tree_select_all(pb, be_list, referral_list, errorbuf);
|
|
|
dc8c34 |
if (((err_code != LDAP_SUCCESS) && (err_code != LDAP_OPERATIONS_ERROR) && (err_code != LDAP_REFERRAL))
|
|
|
dc8c34 |
|| ((err_code == LDAP_OPERATIONS_ERROR) && (be_list[0] == NULL)))
|
|
|
dc8c34 |
-
|
|
|
dc8c34 |
{
|
|
|
dc8c34 |
send_ldap_result(pb, err_code, NULL, errorbuf, 0, NULL);
|
|
|
dc8c34 |
rc = -1;
|
|
|
dc8c34 |
@@ -713,10 +712,6 @@ op_shared_search (Slapi_PBlock *pb, int send_result)
|
|
|
dc8c34 |
curr_search_count = -1;
|
|
|
dc8c34 |
} else {
|
|
|
dc8c34 |
curr_search_count = pnentries;
|
|
|
dc8c34 |
- /* no more entries, but at least another backend */
|
|
|
dc8c34 |
- if (pagedresults_set_current_be(pb->pb_conn, next_be, pr_idx) < 0) {
|
|
|
dc8c34 |
- goto free_and_return;
|
|
|
dc8c34 |
- }
|
|
|
dc8c34 |
}
|
|
|
dc8c34 |
estimate = 0;
|
|
|
dc8c34 |
} else {
|
|
|
dc8c34 |
@@ -731,12 +726,20 @@ op_shared_search (Slapi_PBlock *pb, int send_result)
|
|
|
dc8c34 |
pagedresults_set_search_result_set_size_estimate(pb->pb_conn,
|
|
|
dc8c34 |
operation,
|
|
|
dc8c34 |
estimate, pr_idx);
|
|
|
dc8c34 |
- next_be = NULL; /* to break the loop */
|
|
|
dc8c34 |
- if (curr_search_count == -1) {
|
|
|
dc8c34 |
+ if (PAGEDRESULTS_SEARCH_END == pr_stat) {
|
|
|
dc8c34 |
pagedresults_lock(pb->pb_conn, pr_idx);
|
|
|
dc8c34 |
slapi_pblock_set(pb, SLAPI_SEARCH_RESULT_SET, NULL);
|
|
|
dc8c34 |
pagedresults_free_one(pb->pb_conn, operation, pr_idx);
|
|
|
dc8c34 |
pagedresults_unlock(pb->pb_conn, pr_idx);
|
|
|
dc8c34 |
+ if (next_be) {
|
|
|
dc8c34 |
+ /* no more entries, but at least another backend */
|
|
|
dc8c34 |
+ if (pagedresults_set_current_be(pb->pb_conn, next_be, pr_idx) < 0) {
|
|
|
dc8c34 |
+ goto free_and_return;
|
|
|
dc8c34 |
+ }
|
|
|
dc8c34 |
+ }
|
|
|
dc8c34 |
+ next_be = NULL; /* to break the loop */
|
|
|
dc8c34 |
+ } else if (PAGEDRESULTS_PAGE_END == pr_stat) {
|
|
|
dc8c34 |
+ next_be = NULL; /* to break the loop */
|
|
|
dc8c34 |
}
|
|
|
dc8c34 |
} else {
|
|
|
dc8c34 |
/* be_suffix null means that we are searching the default backend
|
|
|
dc8c34 |
diff --git a/ldap/servers/slapd/pagedresults.c b/ldap/servers/slapd/pagedresults.c
|
|
|
dc8c34 |
index edd76c6..d589708 100644
|
|
|
dc8c34 |
--- a/ldap/servers/slapd/pagedresults.c
|
|
|
dc8c34 |
+++ b/ldap/servers/slapd/pagedresults.c
|
|
|
dc8c34 |
@@ -136,6 +136,7 @@ pagedresults_parse_control_value( Slapi_PBlock *pb,
|
|
|
dc8c34 |
}
|
|
|
dc8c34 |
conn->c_pagedresults.prl_count++;
|
|
|
dc8c34 |
} else {
|
|
|
dc8c34 |
+ PagedResults *prp = NULL;
|
|
|
dc8c34 |
/* Repeated paged results request.
|
|
|
dc8c34 |
* PagedResults is already allocated. */
|
|
|
dc8c34 |
char *ptr = slapi_ch_malloc(cookie.bv_len + 1);
|
|
|
dc8c34 |
@@ -143,6 +144,10 @@ pagedresults_parse_control_value( Slapi_PBlock *pb,
|
|
|
dc8c34 |
*(ptr+cookie.bv_len) = '\0';
|
|
|
dc8c34 |
*index = strtol(ptr, NULL, 10);
|
|
|
dc8c34 |
slapi_ch_free_string(&ptr);
|
|
|
dc8c34 |
+ prp = conn->c_pagedresults.prl_list + *index;
|
|
|
dc8c34 |
+ if (!(prp->pr_search_result_set)) { /* freed and reused for the next backend. */
|
|
|
dc8c34 |
+ conn->c_pagedresults.prl_count++;
|
|
|
dc8c34 |
+ }
|
|
|
dc8c34 |
}
|
|
|
dc8c34 |
/* reset sizelimit */
|
|
|
dc8c34 |
op->o_pagedresults_sizelimit = -1;
|
|
|
dc8c34 |
--
|
|
|
dc8c34 |
1.8.1.4
|
|
|
dc8c34 |
|