amoralej / rpms / 389-ds-base

Forked from rpms/389-ds-base 5 years ago
Clone

Blame SOURCES/0068-Ticket-48146-async-simple-paged-results-issue.patch

df9752
From ef82e8471b3bc171ae99ffd753937b55aa0e6e2f Mon Sep 17 00:00:00 2001
df9752
From: Noriko Hosoi <nhosoi@redhat.com>
df9752
Date: Tue, 26 May 2015 10:41:03 -0700
df9752
Subject: [PATCH 68/72] Ticket #48146 - async simple paged results issue
df9752
df9752
Description: commit 5060d11f5039efa8534a8b65392ac6e10cbd2168 introduced
df9752
a regression.  Handling backend "be" should be done after checking OID
df9752
MTN_CONTROL_USE_ONE_BACKEND_EXT_OID in the request control.
df9752
df9752
https://fedorahosted.org/389/ticket/48146
df9752
df9752
Reviewed by mreynolds@redhat.com (Thank you, Mark!!)
df9752
df9752
(cherry picked from commit bd2c0d0b6a499d7f91a36e8a9feb83e4fbd3dac5)
df9752
(cherry picked from commit 0c7b38abfb4c5c02286efd5e698616534a798993)
df9752
---
df9752
 ldap/servers/slapd/opshared.c | 108 ++++++++++++++++++++++--------------------
df9752
 1 file changed, 57 insertions(+), 51 deletions(-)
df9752
df9752
diff --git a/ldap/servers/slapd/opshared.c b/ldap/servers/slapd/opshared.c
df9752
index 430b0c6..ff67a9b 100644
df9752
--- a/ldap/servers/slapd/opshared.c
df9752
+++ b/ldap/servers/slapd/opshared.c
df9752
@@ -408,57 +408,12 @@ op_shared_search (Slapi_PBlock *pb, int send_result)
df9752
    */
df9752
   operation_set_target_spec (pb->pb_op, basesdn);
df9752
 
df9752
-  if (be_name == NULL)
df9752
-  {
df9752
-    /* no specific backend was requested, use the mapping tree
df9752
-     */
df9752
-    err_code = slapi_mapping_tree_select_all(pb, be_list, referral_list, errorbuf);
df9752
-    if (((err_code != LDAP_SUCCESS) && (err_code != LDAP_OPERATIONS_ERROR) && (err_code != LDAP_REFERRAL))
df9752
-      || ((err_code == LDAP_OPERATIONS_ERROR) && (be_list[0] == NULL)))
df9752
-    {
df9752
-      send_ldap_result(pb, err_code, NULL, errorbuf, 0, NULL);
df9752
-      rc = -1;
df9752
-      goto free_and_return;
df9752
-    }
df9752
-    if (be_list[0] != NULL)
df9752
-    {
df9752
-      index = 0;
df9752
-      if (pr_be) { /* PAGED RESULT: be is found from the previous paging. */
df9752
-        /* move the index in the be_list which matches pr_be */
df9752
-        while (be_list[index] && be_list[index+1] && pr_be != be_list[index])
df9752
-          index++;
df9752
-      } else {
df9752
-        while (be_list[index] && be_list[index+1])
df9752
-          index++;
df9752
-      }
df9752
-      /* "be" is either pr_be or the last backend */
df9752
-      be = be_list[index];
df9752
-    }
df9752
-    else
df9752
-      be = pr_be?pr_be:NULL;
df9752
-  }
df9752
-  else
df9752
-  {
df9752
-      /* specific backend be_name was requested, use slapi_be_select_by_instance_name
df9752
-       */
df9752
-      if (pr_be) {
df9752
-        be_single = be = pr_be;
df9752
-      } else {
df9752
-        be_single = be = slapi_be_select_by_instance_name(be_name);
df9752
-      }
df9752
-      if (be_single)
df9752
-        slapi_be_Rlock(be_single);
df9752
-      be_list[0] = NULL;
df9752
-      referral_list[0] = NULL;
df9752
-      referral = NULL;
df9752
-  }
df9752
-
df9752
-  /* this is time to check if mapping tree specific control
df9752
-   * was used to specify that we want to parse only 
df9752
-   * one backend 
df9752
+  /* 
df9752
+   * this is time to check if mapping tree specific control was used to
df9752
+   * specify that we want to parse only one backend.
df9752
    */
df9752
   slapi_pblock_get(pb, SLAPI_REQCONTROLS, &ctrlp);
df9752
-  if (NULL != ctrlp)
df9752
+  if (ctrlp)
df9752
   {
df9752
       if (slapi_control_present(ctrlp, MTN_CONTROL_USE_ONE_BACKEND_EXT_OID,
df9752
                 &ctl_value, &iscritical))
df9752
@@ -513,7 +468,57 @@ op_shared_search (Slapi_PBlock *pb, int send_result)
df9752
               }
df9752
           }
df9752
       }
df9752
+  }
df9752
+
df9752
+  if (be_name == NULL)
df9752
+  {
df9752
+    /* no specific backend was requested, use the mapping tree
df9752
+     */
df9752
+    err_code = slapi_mapping_tree_select_all(pb, be_list, referral_list, errorbuf);
df9752
+    if (((err_code != LDAP_SUCCESS) && (err_code != LDAP_OPERATIONS_ERROR) && (err_code != LDAP_REFERRAL))
df9752
+      || ((err_code == LDAP_OPERATIONS_ERROR) && (be_list[0] == NULL)))
df9752
+    {
df9752
+      send_ldap_result(pb, err_code, NULL, errorbuf, 0, NULL);
df9752
+      rc = -1;
df9752
+      goto free_and_return;
df9752
+    }
df9752
+    if (be_list[0] != NULL)
df9752
+    {
df9752
+      index = 0;
df9752
+      if (pr_be) { /* PAGED RESULT: be is found from the previous paging. */
df9752
+        /* move the index in the be_list which matches pr_be */
df9752
+        while (be_list[index] && be_list[index+1] && pr_be != be_list[index])
df9752
+          index++;
df9752
+      } else {
df9752
+        while (be_list[index] && be_list[index+1])
df9752
+          index++;
df9752
+      }
df9752
+      /* "be" is either pr_be or the last backend */
df9752
+      be = be_list[index];
df9752
+    }
df9752
+    else
df9752
+      be = pr_be?pr_be:NULL;
df9752
+  }
df9752
+  else
df9752
+  {
df9752
+      /* specific backend be_name was requested, use slapi_be_select_by_instance_name
df9752
+       */
df9752
+      if (pr_be) {
df9752
+        be_single = be = pr_be;
df9752
+      } else {
df9752
+        be_single = be = slapi_be_select_by_instance_name(be_name);
df9752
+      }
df9752
+      if (be_single) {
df9752
+        slapi_be_Rlock(be_single);
df9752
+      }
df9752
+      be_list[0] = NULL;
df9752
+      referral_list[0] = NULL;
df9752
+      referral = NULL;
df9752
+  }
df9752
 
df9752
+  /* Handle the rest of the controls. */
df9752
+  if (ctrlp)
df9752
+  {
df9752
       if ( slapi_control_present (ctrlp, LDAP_CONTROL_GET_EFFECTIVE_RIGHTS,
df9752
                                   &ctl_value, &iscritical) )
df9752
       {
df9752
@@ -1024,10 +1029,11 @@ next_be:
df9752
   }
df9752
 
df9752
 free_and_return:
df9752
-  if ((be_list[0] != NULL) || (referral_list[0] != NULL))
df9752
+  if ((be_list[0] != NULL) || (referral_list[0] != NULL)) {
df9752
     slapi_mapping_tree_free_all(be_list, referral_list);
df9752
-  else if (be_single)
df9752
+  } else if (be_single) {
df9752
     slapi_be_Unlock(be_single);
df9752
+  }
df9752
 
df9752
 free_and_return_nolock:
df9752
   slapi_pblock_set(pb, SLAPI_PLUGIN_OPRETURN, &rc);
df9752
-- 
df9752
1.9.3
df9752