|
|
dc8c34 |
From a05c1c6fd6e2b93e411702674afa8b45c6e8ca30 Mon Sep 17 00:00:00 2001
|
|
|
dc8c34 |
From: Noriko Hosoi <nhosoi@redhat.com>
|
|
|
dc8c34 |
Date: Sat, 30 May 2015 16:44:14 -0700
|
|
|
dc8c34 |
Subject: [PATCH 328/329] Ticket #48146 - async simple paged results issue
|
|
|
dc8c34 |
|
|
|
dc8c34 |
Description: commit 5e9c4f1f09596dd076a6c3a0bb419580e8fd705e broke the
|
|
|
dc8c34 |
CI test case ticket47824_test.py.
|
|
|
dc8c34 |
|
|
|
dc8c34 |
If the simple paged results search is operated on a backend having one
|
|
|
dc8c34 |
or more sub-backends underneath, it fails to pick up the next sub-back
|
|
|
dc8c34 |
ends, but repeats the search on the parent backend. The problem was
|
|
|
dc8c34 |
fixed.
|
|
|
dc8c34 |
|
|
|
dc8c34 |
https://fedorahosted.org/389/ticket/48146
|
|
|
dc8c34 |
|
|
|
dc8c34 |
Reviewed by mreynolds@redhat.com (Thank you, Mark!!)
|
|
|
dc8c34 |
|
|
|
dc8c34 |
(cherry picked from commit 03d3455dfbe84f034a234df2ebd8cfdd7ad15f48)
|
|
|
dc8c34 |
(cherry picked from commit f6fe5bfe4c1fb1402af789a0f935c765c299d103)
|
|
|
dc8c34 |
(cherry picked from commit 64b54d416e75eaeb611ece982c1be9acf3f56161)
|
|
|
dc8c34 |
(cherry picked from commit b50095835b1889f8578ea3da579b543ed1619885)
|
|
|
dc8c34 |
---
|
|
|
dc8c34 |
ldap/servers/slapd/opshared.c | 87 ++++++++++++++++++++-----------------------
|
|
|
dc8c34 |
1 file changed, 41 insertions(+), 46 deletions(-)
|
|
|
dc8c34 |
|
|
|
dc8c34 |
diff --git a/ldap/servers/slapd/opshared.c b/ldap/servers/slapd/opshared.c
|
|
|
dc8c34 |
index bfacb9e..d446f50 100644
|
|
|
dc8c34 |
--- a/ldap/servers/slapd/opshared.c
|
|
|
dc8c34 |
+++ b/ldap/servers/slapd/opshared.c
|
|
|
dc8c34 |
@@ -463,46 +463,31 @@ op_shared_search (Slapi_PBlock *pb, int send_result)
|
|
|
dc8c34 |
}
|
|
|
dc8c34 |
}
|
|
|
dc8c34 |
|
|
|
dc8c34 |
- if (be_name == NULL)
|
|
|
dc8c34 |
- {
|
|
|
dc8c34 |
- /* no specific backend was requested, use the mapping tree
|
|
|
dc8c34 |
- */
|
|
|
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 |
- send_ldap_result(pb, err_code, NULL, errorbuf, 0, NULL);
|
|
|
dc8c34 |
- rc = -1;
|
|
|
dc8c34 |
- goto free_and_return;
|
|
|
dc8c34 |
- }
|
|
|
dc8c34 |
- if (be_list[0] != NULL)
|
|
|
dc8c34 |
- {
|
|
|
dc8c34 |
- index = 0;
|
|
|
dc8c34 |
- if (pr_be) { /* PAGED RESULT: be is found from the previous paging. */
|
|
|
dc8c34 |
- /* move the index in the be_list which matches pr_be */
|
|
|
dc8c34 |
- while (be_list[index] && be_list[index+1] && pr_be != be_list[index])
|
|
|
dc8c34 |
- index++;
|
|
|
dc8c34 |
+ if (be_name == NULL) {
|
|
|
dc8c34 |
+ /* no specific backend was requested, use the mapping tree
|
|
|
dc8c34 |
+ */
|
|
|
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 |
+ send_ldap_result(pb, err_code, NULL, errorbuf, 0, NULL);
|
|
|
dc8c34 |
+ rc = -1;
|
|
|
dc8c34 |
+ goto free_and_return;
|
|
|
dc8c34 |
+ }
|
|
|
dc8c34 |
+ if (be_list[0] != NULL) {
|
|
|
dc8c34 |
+ index = 0;
|
|
|
dc8c34 |
+ while (be_list[index] && be_list[index+1]) {
|
|
|
dc8c34 |
+ index++;
|
|
|
dc8c34 |
+ }
|
|
|
dc8c34 |
+ be = be_list[index];
|
|
|
dc8c34 |
} else {
|
|
|
dc8c34 |
- while (be_list[index] && be_list[index+1])
|
|
|
dc8c34 |
- index++;
|
|
|
dc8c34 |
+ be = NULL;
|
|
|
dc8c34 |
}
|
|
|
dc8c34 |
- /* "be" is either pr_be or the last backend */
|
|
|
dc8c34 |
- be = be_list[index];
|
|
|
dc8c34 |
- }
|
|
|
dc8c34 |
- else
|
|
|
dc8c34 |
- be = pr_be?pr_be:NULL;
|
|
|
dc8c34 |
- }
|
|
|
dc8c34 |
- else
|
|
|
dc8c34 |
- {
|
|
|
dc8c34 |
+ } else {
|
|
|
dc8c34 |
/* specific backend be_name was requested, use slapi_be_select_by_instance_name
|
|
|
dc8c34 |
*/
|
|
|
dc8c34 |
- if (pr_be) {
|
|
|
dc8c34 |
- be_single = be = pr_be;
|
|
|
dc8c34 |
- } else {
|
|
|
dc8c34 |
- be_single = be = slapi_be_select_by_instance_name(be_name);
|
|
|
dc8c34 |
- }
|
|
|
dc8c34 |
+ be_single = be = slapi_be_select_by_instance_name(be_name);
|
|
|
dc8c34 |
if (be_single) {
|
|
|
dc8c34 |
- slapi_be_Rlock(be_single);
|
|
|
dc8c34 |
+ slapi_be_Rlock(be_single);
|
|
|
dc8c34 |
}
|
|
|
dc8c34 |
be_list[0] = NULL;
|
|
|
dc8c34 |
referral_list[0] = NULL;
|
|
|
dc8c34 |
@@ -521,6 +506,7 @@ op_shared_search (Slapi_PBlock *pb, int send_result)
|
|
|
dc8c34 |
if ( slapi_control_present (ctrlp, LDAP_CONTROL_PAGEDRESULTS,
|
|
|
dc8c34 |
&ctl_value, &iscritical) )
|
|
|
dc8c34 |
{
|
|
|
dc8c34 |
+ /* be is set only when this request is new. otherwise, prev be is honored. */
|
|
|
dc8c34 |
rc = pagedresults_parse_control_value(pb, ctl_value, &pagesize, &pr_idx, be);
|
|
|
dc8c34 |
/* Let's set pr_idx even if it fails; in case, pr_idx == -1. */
|
|
|
dc8c34 |
slapi_pblock_set(pb, SLAPI_PAGED_RESULTS_INDEX, &pr_idx);
|
|
|
dc8c34 |
@@ -529,13 +515,24 @@ op_shared_search (Slapi_PBlock *pb, int send_result)
|
|
|
dc8c34 |
unsigned int opnote = SLAPI_OP_NOTE_SIMPLEPAGED;
|
|
|
dc8c34 |
op_set_pagedresults(operation);
|
|
|
dc8c34 |
pr_be = pagedresults_get_current_be(pb->pb_conn, pr_idx);
|
|
|
dc8c34 |
- pr_search_result = pagedresults_get_search_result(pb->pb_conn,
|
|
|
dc8c34 |
- operation,
|
|
|
dc8c34 |
- pr_idx);
|
|
|
dc8c34 |
- estimate =
|
|
|
dc8c34 |
- pagedresults_get_search_result_set_size_estimate(pb->pb_conn,
|
|
|
dc8c34 |
- operation,
|
|
|
dc8c34 |
- pr_idx);
|
|
|
dc8c34 |
+ if (be_name) {
|
|
|
dc8c34 |
+ if (pr_be != be_single) {
|
|
|
dc8c34 |
+ slapi_be_Unlock(be_single);
|
|
|
dc8c34 |
+ be_single = be = pr_be;
|
|
|
dc8c34 |
+ slapi_be_Rlock(be_single);
|
|
|
dc8c34 |
+ }
|
|
|
dc8c34 |
+ } else if (be_list[0]) {
|
|
|
dc8c34 |
+ if (pr_be) { /* PAGED RESULT: be is found from the previous paging. */
|
|
|
dc8c34 |
+ /* move the index in the be_list which matches pr_be */
|
|
|
dc8c34 |
+ index = 0;
|
|
|
dc8c34 |
+ while (be_list[index] && be_list[index+1] && pr_be != be_list[index]) {
|
|
|
dc8c34 |
+ index++;
|
|
|
dc8c34 |
+ }
|
|
|
dc8c34 |
+ be = be_list[index];
|
|
|
dc8c34 |
+ }
|
|
|
dc8c34 |
+ }
|
|
|
dc8c34 |
+ pr_search_result = pagedresults_get_search_result(pb->pb_conn, operation, pr_idx);
|
|
|
dc8c34 |
+ estimate = pagedresults_get_search_result_set_size_estimate(pb->pb_conn, operation, pr_idx);
|
|
|
dc8c34 |
if (pagedresults_get_unindexed(pb->pb_conn, operation, pr_idx)) {
|
|
|
dc8c34 |
opnote |= SLAPI_OP_NOTE_UNINDEXED;
|
|
|
dc8c34 |
}
|
|
|
dc8c34 |
@@ -680,7 +677,7 @@ op_shared_search (Slapi_PBlock *pb, int send_result)
|
|
|
dc8c34 |
* change ONE-LEVEL searches to BASE
|
|
|
dc8c34 |
*/
|
|
|
dc8c34 |
|
|
|
dc8c34 |
- /* that's mean we only support one suffix per backend */
|
|
|
dc8c34 |
+ /* that means we only support one suffix per backend */
|
|
|
dc8c34 |
be_suffix = slapi_be_getsuffix(be, 0);
|
|
|
dc8c34 |
|
|
|
dc8c34 |
if (be_list[0] == NULL)
|
|
|
dc8c34 |
@@ -704,9 +701,7 @@ op_shared_search (Slapi_PBlock *pb, int send_result)
|
|
|
dc8c34 |
* In async paged result case, the search result might be released
|
|
|
dc8c34 |
* by other theads. We need to double check it in the locked region.
|
|
|
dc8c34 |
*/
|
|
|
dc8c34 |
- pr_search_result = pagedresults_get_search_result(pb->pb_conn,
|
|
|
dc8c34 |
- operation,
|
|
|
dc8c34 |
- pr_idx);
|
|
|
dc8c34 |
+ pr_search_result = pagedresults_get_search_result(pb->pb_conn, operation, pr_idx);
|
|
|
dc8c34 |
if (pr_search_result) {
|
|
|
dc8c34 |
slapi_pblock_set( pb, SLAPI_SEARCH_RESULT_SET, pr_search_result );
|
|
|
dc8c34 |
rc = send_results_ext (pb, 1, &pnentries, pagesize, &pr_stat);
|
|
|
dc8c34 |
--
|
|
|
dc8c34 |
1.9.3
|
|
|
dc8c34 |
|