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

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