Blame SOURCES/0027-BE-search-with-sysdb_search_with_ts_attr.patch

d6181b
From a5cd021e92695ccf45be92e5b05394f46ccebd2e Mon Sep 17 00:00:00 2001
d6181b
From: Jakub Hrozek <jhrozek@redhat.com>
d6181b
Date: Tue, 28 May 2019 14:56:15 +0200
d6181b
Subject: [PATCH 27/48] BE: search with sysdb_search_with_ts_attr
d6181b
d6181b
Previously, the background refresh code had used sysdb_search_entry()
d6181b
which does not run the search on the timestamp cache. Instead, this
d6181b
patch changes to using sysdb_search_with_ts_attr with the
d6181b
SYSDB_SEARCH_WITH_TS_ONLY_TS_FILTER optimization because currently only
d6181b
the dataExpireTimestamp attribute is included in the filter.
d6181b
d6181b
Related:
d6181b
https://pagure.io/SSSD/sssd/issue/4012
d6181b
d6181b
Reviewed-by: Sumit Bose <sbose@redhat.com>
d6181b
---
d6181b
 src/providers/be_refresh.c | 19 +++++++++----------
d6181b
 1 file changed, 9 insertions(+), 10 deletions(-)
d6181b
d6181b
diff --git a/src/providers/be_refresh.c b/src/providers/be_refresh.c
d6181b
index e8cf5da75..c6bb66b68 100644
d6181b
--- a/src/providers/be_refresh.c
d6181b
+++ b/src/providers/be_refresh.c
d6181b
@@ -40,9 +40,8 @@ static errno_t be_refresh_get_values_ex(TALLOC_CTX *mem_ctx,
d6181b
     const char *attrs[] = {attr, NULL};
d6181b
     const char *filter = NULL;
d6181b
     char **values = NULL;
d6181b
-    struct ldb_message **msgs = NULL;
d6181b
     struct sysdb_attrs **records = NULL;
d6181b
-    size_t count;
d6181b
+    struct ldb_result *res;
d6181b
     time_t now = time(NULL);
d6181b
     errno_t ret;
d6181b
 
d6181b
@@ -58,23 +57,23 @@ static errno_t be_refresh_get_values_ex(TALLOC_CTX *mem_ctx,
d6181b
         goto done;
d6181b
     }
d6181b
 
d6181b
-    ret = sysdb_search_entry(tmp_ctx, domain->sysdb, base_dn,
d6181b
-                             LDB_SCOPE_SUBTREE, filter, attrs,
d6181b
-                             &count, &msgs);
d6181b
-    if (ret == ENOENT) {
d6181b
-        count = 0;
d6181b
-    } else if (ret != EOK) {
d6181b
+    ret = sysdb_search_with_ts_attr(tmp_ctx, domain, base_dn,
d6181b
+                                    LDB_SCOPE_SUBTREE,
d6181b
+                                    SYSDB_SEARCH_WITH_TS_ONLY_TS_FILTER,
d6181b
+                                    filter, attrs,
d6181b
+                                    &res;;
d6181b
+    if (ret != EOK) {
d6181b
         goto done;
d6181b
     }
d6181b
 
d6181b
-    ret = sysdb_msg2attrs(tmp_ctx, count, msgs, &records);
d6181b
+    ret = sysdb_msg2attrs(tmp_ctx, res->count, res->msgs, &records);
d6181b
     if (ret != EOK) {
d6181b
         DEBUG(SSSDBG_CRIT_FAILURE,
d6181b
               "Could not convert ldb message to sysdb_attrs\n");
d6181b
         goto done;
d6181b
     }
d6181b
 
d6181b
-    ret = sysdb_attrs_to_list(tmp_ctx, records, count, attr, &values);
d6181b
+    ret = sysdb_attrs_to_list(tmp_ctx, records, res->count, attr, &values);
d6181b
     if (ret != EOK) {
d6181b
         goto done;
d6181b
     }
d6181b
-- 
d6181b
2.20.1
d6181b