andykimpe / rpms / 389-ds-base

Forked from rpms/389-ds-base 5 months ago
Clone
dc8c34
From 0d3d5aeb4042d64e03cffa30cec3ff47771e6b42 Mon Sep 17 00:00:00 2001
dc8c34
From: Noriko Hosoi <nhosoi@redhat.com>
dc8c34
Date: Tue, 26 May 2015 10:41:03 -0700
dc8c34
Subject: [PATCH 327/327] Ticket #48146 - async simple paged results issue
dc8c34
dc8c34
Description: commit 5060d11f5039efa8534a8b65392ac6e10cbd2168 introduced
dc8c34
a regression.  Handling backend "be" should be done after checking OID
dc8c34
MTN_CONTROL_USE_ONE_BACKEND_EXT_OID in the request control.
dc8c34
dc8c34
https://fedorahosted.org/389/ticket/48146
dc8c34
dc8c34
Reviewed by mreynolds@redhat.com (Thank you, Mark!!)
dc8c34
dc8c34
(cherry picked from commit bd2c0d0b6a499d7f91a36e8a9feb83e4fbd3dac5)
dc8c34
(cherry picked from commit 0c7b38abfb4c5c02286efd5e698616534a798993)
dc8c34
(cherry picked from commit 2003d79eb3fbd3850c9a2590c65fbe146e96853d)
dc8c34
(cherry picked from commit 52a7299d243278de0e1877714f5ff65a5c542b5e)
dc8c34
---
dc8c34
 ldap/servers/slapd/opshared.c | 108 ++++++++++++++++++++++--------------------
dc8c34
 1 file changed, 57 insertions(+), 51 deletions(-)
dc8c34
dc8c34
diff --git a/ldap/servers/slapd/opshared.c b/ldap/servers/slapd/opshared.c
dc8c34
index 15b81b6..bfacb9e 100644
dc8c34
--- a/ldap/servers/slapd/opshared.c
dc8c34
+++ b/ldap/servers/slapd/opshared.c
dc8c34
@@ -407,57 +407,12 @@ op_shared_search (Slapi_PBlock *pb, int send_result)
dc8c34
    */
dc8c34
   operation_set_target_spec (pb->pb_op, basesdn);
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
-      } else {
dc8c34
-        while (be_list[index] && be_list[index+1])
dc8c34
-          index++;
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
-      /* 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
-      if (be_single)
dc8c34
-        slapi_be_Rlock(be_single);
dc8c34
-      be_list[0] = NULL;
dc8c34
-      referral_list[0] = NULL;
dc8c34
-      referral = NULL;
dc8c34
-  }
dc8c34
-
dc8c34
-  /* this is time to check if mapping tree specific control
dc8c34
-   * was used to specify that we want to parse only 
dc8c34
-   * one backend 
dc8c34
+  /* 
dc8c34
+   * this is time to check if mapping tree specific control was used to
dc8c34
+   * specify that we want to parse only one backend.
dc8c34
    */
dc8c34
   slapi_pblock_get(pb, SLAPI_REQCONTROLS, &ctrlp);
dc8c34
-  if (NULL != ctrlp)
dc8c34
+  if (ctrlp)
dc8c34
   {
dc8c34
       if (slapi_control_present(ctrlp, MTN_CONTROL_USE_ONE_BACKEND_EXT_OID,
dc8c34
                 &ctl_value, &iscritical))
dc8c34
@@ -506,7 +461,57 @@ op_shared_search (Slapi_PBlock *pb, int send_result)
dc8c34
               }
dc8c34
           }
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
+      } else {
dc8c34
+        while (be_list[index] && be_list[index+1])
dc8c34
+          index++;
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
+      /* 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
+      if (be_single) {
dc8c34
+        slapi_be_Rlock(be_single);
dc8c34
+      }
dc8c34
+      be_list[0] = NULL;
dc8c34
+      referral_list[0] = NULL;
dc8c34
+      referral = NULL;
dc8c34
+  }
dc8c34
 
dc8c34
+  /* Handle the rest of the controls. */
dc8c34
+  if (ctrlp)
dc8c34
+  {
dc8c34
       if ( slapi_control_present (ctrlp, LDAP_CONTROL_GET_EFFECTIVE_RIGHTS,
dc8c34
                                   &ctl_value, &iscritical) )
dc8c34
       {
dc8c34
@@ -1017,10 +1022,11 @@ next_be:
dc8c34
   }
dc8c34
 
dc8c34
 free_and_return:
dc8c34
-  if ((be_list[0] != NULL) || (referral_list[0] != NULL))
dc8c34
+  if ((be_list[0] != NULL) || (referral_list[0] != NULL)) {
dc8c34
     slapi_mapping_tree_free_all(be_list, referral_list);
dc8c34
-  else if (be_single)
dc8c34
+  } else if (be_single) {
dc8c34
     slapi_be_Unlock(be_single);
dc8c34
+  }
dc8c34
 
dc8c34
 free_and_return_nolock:
dc8c34
   slapi_pblock_set(pb, SLAPI_PLUGIN_OPRETURN, &rc);
dc8c34
-- 
dc8c34
1.9.3
dc8c34