dsdb: Rework more KCC service-specific details out of dsdb_garbage_collect_tombstones()
authorAndrew Bartlett <abartlet@samba.org>
Mon, 29 Aug 2016 06:56:10 +0000 (18:56 +1200)
committerGarming Sam <garming@samba.org>
Thu, 1 Sep 2016 03:49:14 +0000 (05:49 +0200)
Signed-off-by: Andrew Bartlett <abartlet@samba.org>
Reviewed-by: Garming Sam <garming@catalyst.net.nz>
source4/dsdb/kcc/garbage_collect_tombstones.c
source4/dsdb/kcc/garbage_collect_tombstones.h
source4/dsdb/kcc/kcc_periodic.c

index 825cfe2d2985131d65e5001ac8293ec35cad2b92..80b30ebae2a4cf6b0a89fbffbbb1bfaad5723809 100644 (file)
 NTSTATUS dsdb_garbage_collect_tombstones(TALLOC_CTX *mem_ctx, struct loadparm_context *lp_ctx,
                                         struct ldb_context *samdb,
                                         struct dsdb_ldb_dn_list_node *part,
-                                        time_t current_time, time_t *last_deleted_check,
-                                        time_t *last_full_scan_deleted_check)
+                                        time_t current_time,
+                                        bool do_fs)
 {
        int ret;
        uint32_t tombstoneLifetime;
-       bool do_fs = false;
-
-       time_t interval = lpcfg_parm_int(lp_ctx, NULL, "kccsrv",
-                                        "check_deleted_full_scan_interval", 86400);
-
-       if (current_time - *last_deleted_check < lpcfg_parm_int(lp_ctx, NULL, "kccsrv",
-                                                                 "check_deleted_interval", 600)) {
-               return NT_STATUS_OK;
-       }
-       *last_deleted_check = current_time;
 
        ret = dsdb_tombstone_lifetime(samdb, &tombstoneLifetime);
        if (ret != LDB_SUCCESS) {
                DEBUG(1,(__location__ ": Failed to get tombstone lifetime\n"));
                return NT_STATUS_INTERNAL_DB_CORRUPTION;
        }
-       if (*last_full_scan_deleted_check > 0 && ((current_time - *last_full_scan_deleted_check) > interval )) {
-               do_fs = true;
-               *last_full_scan_deleted_check = current_time;
-       }
-
-       if (*last_full_scan_deleted_check == 0) {
-               /*
-                * If we never made a full scan set the last full scan event to be in the past
-                * and that 9/10 of the full scan interval has already passed.
-                * This is done to avoid the full scan to fire just at the begining of samba
-                * or a couple of minutes after the start.
-                * With this "setup" and default values of interval, the full scan will fire
-                * 2.4 hours after the start of samba
-                */
-               *last_full_scan_deleted_check = current_time - ((9 * interval) / 10);
-       }
 
        for (; part != NULL; part = part->next) {
                struct ldb_dn *do_dn;
index b41bc9dc749f88559f3a55736194a8527cc726fb..445c7b3ba5d4c135a9c9f0fcf590a089f7a117f2 100644 (file)
@@ -27,5 +27,5 @@
 NTSTATUS dsdb_garbage_collect_tombstones(TALLOC_CTX *mem_ctx, struct loadparm_context *lp_ctx,
                                         struct ldb_context *samdb,
                                         struct dsdb_ldb_dn_list_node *part,
-                                        time_t current_time, time_t *last_deleted_check,
-                                        time_t *last_full_scan_deleted_check);
+                                        time_t current_time,
+                                        bool do_fs);
index ef114fd13cbdda54a149eff5f40983bc579c5a72..5b5d36ed0ae5e723f5d18941f311d223d0f20f5c 100644 (file)
@@ -601,10 +601,36 @@ WERROR kccsrv_periodic_schedule(struct kccsrv_service *service, uint32_t next_in
  */
 static NTSTATUS kccsrv_check_deleted(struct kccsrv_service *s, TALLOC_CTX *mem_ctx)
 {
+       bool do_fs = false;
        time_t current = time(NULL);
+       time_t interval = lpcfg_parm_int(s->task->lp_ctx, NULL, "kccsrv",
+                                        "check_deleted_full_scan_interval", 86400);
+
+       if (current - s->last_deleted_check < lpcfg_parm_int(s->task->lp_ctx, NULL, "kccsrv",
+                                                                 "check_deleted_interval", 600)) {
+               return NT_STATUS_OK;
+       }
+       s->last_deleted_check = current;
+
+       if (s->last_full_scan_deleted_check > 0 && ((current - s->last_full_scan_deleted_check) > interval )) {
+               do_fs = true;
+               s->last_full_scan_deleted_check = current;
+       }
+
+       if (s->last_full_scan_deleted_check == 0) {
+               /*
+                * If we never made a full scan set the last full scan event to be in the past
+                * and that 9/10 of the full scan interval has already passed.
+                * This is done to avoid the full scan to fire just at the begining of samba
+                * or a couple of minutes after the start.
+                * With this "setup" and default values of interval, the full scan will fire
+                * 2.4 hours after the start of samba
+                */
+               s->last_full_scan_deleted_check = current - ((9 * interval) / 10);
+       }
+
        return dsdb_garbage_collect_tombstones(mem_ctx, s->task->lp_ctx, s->samdb,
-                                              s->partitions, current, &s->last_deleted_check,
-                                              &s->last_full_scan_deleted_check);
+                                              s->partitions, current, do_fs);
 }
 
 static void kccsrv_periodic_run(struct kccsrv_service *service)