From fd0eda247cc2b32d03e3fc42342ebe72b4b71976 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Pavel=20B=C5=99ezina?= <pbrezina@redhat.com>
Date: Mon, 10 Jun 2013 11:55:48 +0200
Subject: [PATCH] changes to 1st and 4th patch

---
 src/providers/dp_ptask.c   |  5 +++++
 src/providers/dp_ptask.h   |  2 ++
 src/providers/dp_refresh.c | 12 +++++++++---
 3 files changed, 16 insertions(+), 3 deletions(-)

diff --git a/src/providers/dp_ptask.c b/src/providers/dp_ptask.c
index 423052a5a436c0a0e0841d2211960e602da64240..d3580981b4abea8471c280a647eb558341d738ef 100644
--- a/src/providers/dp_ptask.c
+++ b/src/providers/dp_ptask.c
@@ -347,3 +347,8 @@ void be_ptask_destroy(struct be_ptask **task)
 {
     talloc_zfree(*task);
 }
+
+time_t be_ptask_get_period(struct be_ptask *task)
+{
+    return task->period;
+}
diff --git a/src/providers/dp_ptask.h b/src/providers/dp_ptask.h
index d40485530772dc8d2319ba5ae64afd360293bddc..ae5f78d586df69bdcfa34bb35f032ad1dbd1b983 100644
--- a/src/providers/dp_ptask.h
+++ b/src/providers/dp_ptask.h
@@ -91,4 +91,6 @@ void be_ptask_enable(struct be_ptask *task);
 void be_ptask_disable(struct be_ptask *task);
 void be_ptask_destroy(struct be_ptask **task);
 
+time_t be_ptask_get_period(struct be_ptask *task);
+
 #endif /* _DP_PTASK_H_ */
diff --git a/src/providers/dp_refresh.c b/src/providers/dp_refresh.c
index 5b0a394a2bdd14519b0d9508b03a8e2b3c73115e..59d858549d94660e4abd4f5610eda13dabb9b495 100644
--- a/src/providers/dp_refresh.c
+++ b/src/providers/dp_refresh.c
@@ -31,6 +31,7 @@
 
 static errno_t be_refresh_get_values(TALLOC_CTX *mem_ctx,
                                      struct sss_domain_info *domain,
+                                     time_t period,
                                      const char *objectclass,
                                      struct ldb_dn *base_dn,
                                      const char *attr,
@@ -52,7 +53,7 @@ static errno_t be_refresh_get_values(TALLOC_CTX *mem_ctx,
     }
 
     filter = talloc_asprintf(tmp_ctx, "(&(%s<=%lld))",
-                             SYSDB_CACHE_EXPIRE, (long long) now);
+                             SYSDB_CACHE_EXPIRE, (long long) now + period);
     if (filter == NULL) {
         ret = ENOMEM;
         goto done;
@@ -90,6 +91,7 @@ done:
 
 static errno_t be_refresh_get_netgroups(TALLOC_CTX *mem_ctx,
                                         struct sss_domain_info *domain,
+                                        time_t period,
                                         char ***_values)
 {
     struct ldb_dn *base_dn = NULL;
@@ -100,7 +102,7 @@ static errno_t be_refresh_get_netgroups(TALLOC_CTX *mem_ctx,
         return ENOMEM;
     }
 
-    ret = be_refresh_get_values(mem_ctx, domain, SYSDB_NETGROUP_CLASS,
+    ret = be_refresh_get_values(mem_ctx, domain, period, SYSDB_NETGROUP_CLASS,
                                 base_dn, SYSDB_NAME, _values);
 
     talloc_free(base_dn);
@@ -110,6 +112,7 @@ static errno_t be_refresh_get_netgroups(TALLOC_CTX *mem_ctx,
 typedef errno_t
 (*be_refresh_get_values_t)(TALLOC_CTX *mem_ctx,
                            struct sss_domain_info *domain,
+                           time_t period,
                            char ***_values);
 
 
@@ -169,6 +172,7 @@ struct be_refresh_state {
     struct be_refresh_ctx *ctx;
     struct be_refresh_cb *cb;
     enum be_refresh_type index;
+    time_t period;
 };
 
 static errno_t be_refresh_step(struct tevent_req *req);
@@ -193,6 +197,7 @@ struct tevent_req *be_refresh_send(TALLOC_CTX *mem_ctx,
 
     state->ev = ev;
     state->be_ctx = be_ctx;
+    state->period = be_ptask_get_period(be_ptask);
     state->ctx = talloc_get_type(pvt, struct be_refresh_ctx);
     if (state->ctx == NULL) {
         ret = EINVAL;
@@ -247,7 +252,8 @@ static errno_t be_refresh_step(struct tevent_req *req)
         goto done;
     }
 
-    ret = state->cb->get_values(state, state->be_ctx->domain, &values);
+    ret = state->cb->get_values(state, state->be_ctx->domain, state->period,
+                                &values);
     if (ret != EOK) {
         DEBUG(SSSDBG_CRIT_FAILURE, ("Unable to obtain DN list [%d]: %s\n",
                                     ret, sss_strerror(ret)));
-- 
1.7.11.7

