From 18d4cc94981551b87340244daeda3b4f20c82511 Mon Sep 17 00:00:00 2001
From: Ludwig Krispenz <lkrispen@redhat.com>
Date: Tue, 8 Aug 2017 13:51:05 +0200
Subject: [PATCH] Ticket 49445 - remove dead code

---
 ldap/servers/plugins/chainingdb/cb_init.c      |  1 -
 ldap/servers/slapd/back-ldbm/close.c           | 14 --------------
 ldap/servers/slapd/back-ldbm/dblayer.c         | 11 -----------
 ldap/servers/slapd/back-ldbm/import.c          |  4 ----
 ldap/servers/slapd/back-ldbm/init.c            |  2 --
 ldap/servers/slapd/back-ldbm/ldif2ldbm.c       | 20 --------------------
 ldap/servers/slapd/back-ldbm/proto-back-ldbm.h |  2 --
 ldap/servers/slapd/backend.c                   |  6 ------
 ldap/servers/slapd/backend_manager.c           | 23 -----------------------
 ldap/servers/slapd/daemon.c                    |  2 --
 ldap/servers/slapd/house.c                     |  2 --
 ldap/servers/slapd/ldbmlinktest.c              |  1 -
 ldap/servers/slapd/pblock.c                    |  9 ---------
 ldap/servers/slapd/proto-slap.h                |  1 -
 ldap/servers/slapd/slap.h                      |  3 ---
 ldap/servers/slapd/slapi-private.h             |  1 -
 src/contrib/back-ldif/back-ldif.h              |  1 -
 src/contrib/back-ldif/close.c                  | 15 ---------------
 src/contrib/back-ldif/init.c                   |  2 --
 test/libslapd/pblock/pblock_accessors.txt      |  1 -
 test/libslapd/pblock/pblock_accessors_freq.txt |  2 --
 21 files changed, 123 deletions(-)

diff --git a/ldap/servers/plugins/chainingdb/cb_init.c b/ldap/servers/plugins/chainingdb/cb_init.c
index 095a3a4..28b97e9 100644
--- a/ldap/servers/plugins/chainingdb/cb_init.c
+++ b/ldap/servers/plugins/chainingdb/cb_init.c
@@ -106,7 +106,6 @@ chaining_back_init(Slapi_PBlock *pb)
     /*
     ** The following callbacks are not implemented
     ** by the chaining backend
-    **    - SLAPI_PLUGIN_DB_FLUSH_FN
     **     - SLAPI_PLUGIN_DB_SEQ_FN
     **      - SLAPI_PLUGIN_DB_RMDB_FN
     **     - SLAPI_PLUGIN_DB_DB2INDEX_FN
diff --git a/ldap/servers/slapd/back-ldbm/close.c b/ldap/servers/slapd/back-ldbm/close.c
index 819bc37..833cb9d 100644
--- a/ldap/servers/slapd/back-ldbm/close.c
+++ b/ldap/servers/slapd/back-ldbm/close.c
@@ -28,8 +28,6 @@ ldbm_back_close(Slapi_PBlock *pb)
     li->li_shutdown = 1;
     PR_Unlock(li->li_shutdown_mutex);
 
-    dblayer_flush(li); /* just be doubly sure! */
-
     /* close down all the ldbm instances */
     dblayer_close(li, DBLAYER_NORMAL_MODE);
 
@@ -40,18 +38,6 @@ ldbm_back_close(Slapi_PBlock *pb)
     return 0;
 }
 
-int
-ldbm_back_flush(Slapi_PBlock *pb)
-{
-    struct ldbminfo *li;
-
-    slapi_log_err(SLAPI_LOG_TRACE, "ldbm_back_close", "ldbm backend flushing\n");
-    slapi_pblock_get(pb, SLAPI_PLUGIN_PRIVATE, &li);
-    dblayer_flush(li);
-    slapi_log_err(SLAPI_LOG_TRACE, "ldbm_back_close", "ldbm backend done flushing\n");
-    return 0;
-}
-
 void
 ldbm_back_instance_set_destructor(void **arg __attribute__((unused)))
 {
diff --git a/ldap/servers/slapd/back-ldbm/dblayer.c b/ldap/servers/slapd/back-ldbm/dblayer.c
index 620af6a..6d23cd5 100644
--- a/ldap/servers/slapd/back-ldbm/dblayer.c
+++ b/ldap/servers/slapd/back-ldbm/dblayer.c
@@ -2584,17 +2584,6 @@ dblayer_close(struct ldbminfo *li, int dbmode)
     return return_value;
 }
 
-/*
- * Called to tell us to flush any data not on disk to the disk
- * for the transacted database, we interpret this as an instruction
- * to write a checkpoint.
- */
-int
-dblayer_flush(struct ldbminfo *li __attribute__((unused)))
-{
-    return 0;
-}
-
 /* API to remove the environment */
 int
 dblayer_remove_env(struct ldbminfo *li)
diff --git a/ldap/servers/slapd/back-ldbm/import.c b/ldap/servers/slapd/back-ldbm/import.c
index a9aa54f..e8f4a56 100644
--- a/ldap/servers/slapd/back-ldbm/import.c
+++ b/ldap/servers/slapd/back-ldbm/import.c
@@ -1454,10 +1454,6 @@ import_main_offline(void *arg)
     }
 
     import_log_notice(job, SLAPI_LOG_INFO, "import_main_offline", "Flushing caches...");
-    if (0 != (ret = dblayer_flush(job->inst->inst_li))) {
-        import_log_notice(job, SLAPI_LOG_ERR, "import_main_offline", "Failed to flush database");
-        goto error;
-    }
 
 /* New way to exit the routine: check the return code.
      * If it's non-zero, delete the database files.
diff --git a/ldap/servers/slapd/back-ldbm/init.c b/ldap/servers/slapd/back-ldbm/init.c
index ece252a..1048574 100644
--- a/ldap/servers/slapd/back-ldbm/init.c
+++ b/ldap/servers/slapd/back-ldbm/init.c
@@ -158,8 +158,6 @@ ldbm_back_init(Slapi_PBlock *pb)
                            (void *)ldbm_back_close);
     rc |= slapi_pblock_set(pb, SLAPI_PLUGIN_CLEANUP_FN,
                            (void *)ldbm_back_cleanup);
-    rc |= slapi_pblock_set(pb, SLAPI_PLUGIN_DB_FLUSH_FN,
-                           (void *)ldbm_back_flush);
     rc |= slapi_pblock_set(pb, SLAPI_PLUGIN_START_FN,
                            (void *)ldbm_back_start);
     rc |= slapi_pblock_set(pb, SLAPI_PLUGIN_DB_SEQ_FN,
diff --git a/ldap/servers/slapd/back-ldbm/ldif2ldbm.c b/ldap/servers/slapd/back-ldbm/ldif2ldbm.c
index d603cca..4347c17 100644
--- a/ldap/servers/slapd/back-ldbm/ldif2ldbm.c
+++ b/ldap/servers/slapd/back-ldbm/ldif2ldbm.c
@@ -1646,11 +1646,6 @@ bye:
     slapi_log_err(SLAPI_LOG_TRACE, "ldbm_back_ldbm2ldif", "<=\n");
 
     if (we_start_the_backends && NULL != li) {
-        if (0 != dblayer_flush(li)) {
-            slapi_log_err(SLAPI_LOG_ERR,
-                          "ldbm_back_ldbm2ldif", "db2ldif: Failed to flush database\n");
-        }
-
         if (0 != dblayer_close(li, DBLAYER_EXPORT_MODE)) {
             slapi_log_err(SLAPI_LOG_ERR,
                           "ldbm_back_ldbm2ldif", "db2ldif: Failed to close database\n");
@@ -2597,10 +2592,6 @@ err_min:
     instance_set_not_busy(inst);
 
     if (run_from_cmdline) {
-        if (0 != dblayer_flush(li)) {
-            slapi_log_err(SLAPI_LOG_ERR,
-                          "ldbm_back_ldbm2index", "%s: Failed to flush database\n", inst->inst_name);
-        }
         dblayer_instance_close(be);
         if (0 != dblayer_close(li, DBLAYER_INDEX_MODE)) {
             slapi_log_err(SLAPI_LOG_ERR,
@@ -3000,10 +2991,6 @@ ldbm_back_upgradedb(Slapi_PBlock *pb)
 
     /* close the database down again */
     if (run_from_cmdline) {
-        if (0 != dblayer_flush(li)) {
-            slapi_log_err(SLAPI_LOG_ERR, "ldbm_back_upgradedb",
-                          "Failed to flush database\n");
-        }
         if (0 != dblayer_close(li, DBLAYER_IMPORT_MODE)) {
             slapi_log_err(SLAPI_LOG_ERR, "ldbm_back_upgradedb",
                           "Failed to close database\n");
@@ -3024,9 +3011,6 @@ ldbm_back_upgradedb(Slapi_PBlock *pb)
     return 0;
 
 fail1:
-    if (0 != dblayer_flush(li))
-        slapi_log_err(SLAPI_LOG_ERR, "ldbm_back_upgradedb",
-                      "Failed to flush database\n");
 
     /* we started dblayer with DBLAYER_IMPORT_MODE
      * We just want not to generate a guardian file...
@@ -3785,10 +3769,6 @@ ldbm_back_upgradednformat(Slapi_PBlock *pb)
 
     /* close the database */
     if (run_from_cmdline) {
-        if (0 != dblayer_flush(li)) {
-            slapi_log_err(SLAPI_LOG_ERR, "ldbm_back_upgradednformat",
-                          "Failed to flush database\n");
-        }
         if (0 != dblayer_close(li, DBLAYER_IMPORT_MODE)) {
             slapi_log_err(SLAPI_LOG_ERR, "ldbm_back_upgradednformat",
                           "Failed to close database\n");
diff --git a/ldap/servers/slapd/back-ldbm/proto-back-ldbm.h b/ldap/servers/slapd/back-ldbm/proto-back-ldbm.h
index 1323c53..0cee3df 100644
--- a/ldap/servers/slapd/back-ldbm/proto-back-ldbm.h
+++ b/ldap/servers/slapd/back-ldbm/proto-back-ldbm.h
@@ -73,7 +73,6 @@ struct backdn *dncache_find_id(struct cache *cache, ID id);
 int dblayer_init(struct ldbminfo *li);
 int dblayer_terminate(struct ldbminfo *li);
 int dblayer_start(struct ldbminfo *li, int dbmode);
-int dblayer_flush(struct ldbminfo *li);
 int dblayer_close(struct ldbminfo *li, int dbmode);
 void dblayer_pre_close(struct ldbminfo *li);
 int dblayer_post_close(struct ldbminfo *li, int dbmode);
@@ -475,7 +474,6 @@ int ldbm_back_config(Slapi_PBlock *pb);
 int ldbm_back_close(Slapi_PBlock *pb);
 int ldbm_back_cleanup(Slapi_PBlock *pb);
 void ldbm_back_instance_set_destructor(void **arg);
-int ldbm_back_flush(Slapi_PBlock *pb);
 int ldbm_back_start(Slapi_PBlock *pb);
 int ldbm_back_seq(Slapi_PBlock *pb);
 int ldbm_back_ldif2ldbm(Slapi_PBlock *pb);
diff --git a/ldap/servers/slapd/backend.c b/ldap/servers/slapd/backend.c
index f08280a..fb3eb77 100644
--- a/ldap/servers/slapd/backend.c
+++ b/ldap/servers/slapd/backend.c
@@ -392,9 +392,6 @@ slapi_be_getentrypoint(Slapi_Backend *be, int entrypoint, void **ret_fnptr, Slap
     case SLAPI_PLUGIN_CLOSE_FN:
         *ret_fnptr = (void *)be->be_close;
         break;
-    case SLAPI_PLUGIN_DB_FLUSH_FN:
-        *ret_fnptr = (void *)be->be_flush;
-        break;
     case SLAPI_PLUGIN_START_FN:
         *ret_fnptr = (void *)be->be_start;
         break;
@@ -504,9 +501,6 @@ slapi_be_setentrypoint(Slapi_Backend *be, int entrypoint, void *ret_fnptr, Slapi
     case SLAPI_PLUGIN_CLOSE_FN:
         be->be_close = (IFP)ret_fnptr;
         break;
-    case SLAPI_PLUGIN_DB_FLUSH_FN:
-        be->be_flush = (IFP)ret_fnptr;
-        break;
     case SLAPI_PLUGIN_START_FN:
         be->be_start = (IFP)ret_fnptr;
         break;
diff --git a/ldap/servers/slapd/backend_manager.c b/ldap/servers/slapd/backend_manager.c
index 25bd3de..8ea433c 100644
--- a/ldap/servers/slapd/backend_manager.c
+++ b/ldap/servers/slapd/backend_manager.c
@@ -288,29 +288,6 @@ be_cleanupall()
     slapi_ch_free((void **)&backends);
 }
 
-/*
- * This ifdef is needed to resolve a gcc 6 issue which throws a false positive
- * here. See also: https://bugzilla.redhat.com/show_bug.cgi?id=1386445
- *
- * It's a good idea to run this in EL7 to check the overflows etc, but with
- * GCC 6 and lsan to find memory leaks ....
- */
-void
-be_flushall()
-{
-    for (size_t i = 0; i < maxbackends; i++) {
-        if (backends[i] &&
-            backends[i]->be_state == BE_STATE_STARTED &&
-            backends[i]->be_flush != NULL) {
-            Slapi_PBlock *pb = slapi_pblock_new();
-            slapi_pblock_set(pb, SLAPI_PLUGIN, backends[i]->be_database);
-            slapi_pblock_set(pb, SLAPI_BACKEND, backends[i]);
-            (*backends[i]->be_flush)(pb);
-            slapi_pblock_destroy(pb);
-        }
-    }
-}
-
 void
 be_unbindall(Connection *conn, Operation *op)
 {
diff --git a/ldap/servers/slapd/daemon.c b/ldap/servers/slapd/daemon.c
index 66a87df..4e0466a 100644
--- a/ldap/servers/slapd/daemon.c
+++ b/ldap/servers/slapd/daemon.c
@@ -1172,8 +1172,6 @@ slapd_daemon(daemon_ports_t *ports, ns_thrpool_t *tp)
 #endif
     }
 
-    /* Might compete with housecleaning thread, but so far so good */
-    be_flushall();
     op_thread_cleanup();
     housekeeping_stop(); /* Run this after op_thread_cleanup() logged sth */
     disk_monitoring_stop();
diff --git a/ldap/servers/slapd/house.c b/ldap/servers/slapd/house.c
index 3f96436..ff139a4 100644
--- a/ldap/servers/slapd/house.c
+++ b/ldap/servers/slapd/house.c
@@ -37,8 +37,6 @@ housecleaning(void *cur_time __attribute__((unused)))
         /*
          * Looks simple, but could potentially take a long time.
          */
-        be_flushall();
-
         log_access_flush();
 
         if (g_get_shutdown()) {
diff --git a/ldap/servers/slapd/ldbmlinktest.c b/ldap/servers/slapd/ldbmlinktest.c
index dc7d0b3..edbdf67 100644
--- a/ldap/servers/slapd/ldbmlinktest.c
+++ b/ldap/servers/slapd/ldbmlinktest.c
@@ -30,7 +30,6 @@ main()
     ldbm_back_config();
     ldbm_back_init();
     ldbm_back_close();
-    ldbm_back_flush();
 }
 
 #if 0
diff --git a/ldap/servers/slapd/pblock.c b/ldap/servers/slapd/pblock.c
index 42e2a42..9a9f84e 100644
--- a/ldap/servers/slapd/pblock.c
+++ b/ldap/servers/slapd/pblock.c
@@ -828,9 +828,6 @@ slapi_pblock_get(Slapi_PBlock *pblock, int arg, void *value)
     case SLAPI_PLUGIN_CLEANUP_FN:
         (*(IFP *)value) = pblock->pb_plugin->plg_cleanup;
         break;
-    case SLAPI_PLUGIN_DB_FLUSH_FN:
-        (*(IFP *)value) = pblock->pb_plugin->plg_flush;
-        break;
     case SLAPI_PLUGIN_START_FN:
         (*(IFP *)value) = pblock->pb_plugin->plg_start;
         break;
@@ -2585,12 +2582,6 @@ slapi_pblock_set(Slapi_PBlock *pblock, int arg, void *value)
     case SLAPI_PLUGIN_CLEANUP_FN:
         pblock->pb_plugin->plg_cleanup = (IFP)value;
         break;
-    case SLAPI_PLUGIN_DB_FLUSH_FN:
-        if (pblock->pb_plugin->plg_type != SLAPI_PLUGIN_DATABASE) {
-            return (-1);
-        }
-        pblock->pb_plugin->plg_flush = (IFP)value;
-        break;
     case SLAPI_PLUGIN_START_FN:
         pblock->pb_plugin->plg_start = (IFP)value;
         break;
diff --git a/ldap/servers/slapd/proto-slap.h b/ldap/servers/slapd/proto-slap.h
index daadfe5..b687ba5 100644
--- a/ldap/servers/slapd/proto-slap.h
+++ b/ldap/servers/slapd/proto-slap.h
@@ -192,7 +192,6 @@ Slapi_Backend *be_new_internal(struct dse *pdse, const char *type, const char *n
 void be_replace_dse_internal(Slapi_Backend *be, struct dse *pdse);
 int fedse_create_startOK(char *filename, char *startokfilename, const char *configdir);
 void be_cleanupall(void);
-void be_flushall(void);
 int be_remove(Slapi_Backend *be);
 void g_set_defsize(int val);
 void g_set_deftime(int val);
diff --git a/ldap/servers/slapd/slap.h b/ldap/servers/slapd/slap.h
index 841dc92..cc54a1c 100644
--- a/ldap/servers/slapd/slap.h
+++ b/ldap/servers/slapd/slap.h
@@ -998,7 +998,6 @@ struct slapdplugin
             IFP plg_un_db_delete;               /* delete */
             IFP plg_un_db_abandon;              /* abandon */
             IFP plg_un_db_config;               /* config */
-            IFP plg_un_db_flush;                /* close */
             IFP plg_un_db_seq;                  /* sequence */
             IFP plg_un_db_entry;                /* entry send */
             IFP plg_un_db_referral;             /* referral send */
@@ -1041,7 +1040,6 @@ struct slapdplugin
 #define plg_delete plg_un.plg_un_db.plg_un_db_delete
 #define plg_abandon plg_un.plg_un_db.plg_un_db_abandon
 #define plg_config plg_un.plg_un_db.plg_un_db_config
-#define plg_flush plg_un.plg_un_db.plg_un_db_flush
 #define plg_seq plg_un.plg_un_db.plg_un_db_seq
 #define plg_entry plg_un.plg_un_db.plg_un_db_entry
 #define plg_referral plg_un.plg_un_db.plg_un_db_referral
@@ -1387,7 +1385,6 @@ typedef struct backend
 #define be_abandon be_database->plg_abandon
 #define be_config be_database->plg_config
 #define be_close be_database->plg_close
-#define be_flush be_database->plg_flush
 #define be_start be_database->plg_start
 #define be_poststart be_database->plg_poststart
 #define be_seq be_database->plg_seq
diff --git a/ldap/servers/slapd/slapi-private.h b/ldap/servers/slapd/slapi-private.h
index 87d9367..a26aa2e 100644
--- a/ldap/servers/slapd/slapi-private.h
+++ b/ldap/servers/slapd/slapi-private.h
@@ -879,7 +879,6 @@ int proxyauth_get_dn(Slapi_PBlock *pb, char **proxydnp, char **errtextp);
 #define SLAPI_PLUGIN_DB_DELETE_FN                 207
 #define SLAPI_PLUGIN_DB_ABANDON_FN                208
 #define SLAPI_PLUGIN_DB_CONFIG_FN                 209
-#define SLAPI_PLUGIN_DB_FLUSH_FN                  211
 #define SLAPI_PLUGIN_DB_SEQ_FN                    213
 #define SLAPI_PLUGIN_DB_ENTRY_FN                  214
 #define SLAPI_PLUGIN_DB_REFERRAL_FN               215
diff --git a/src/contrib/back-ldif/back-ldif.h b/src/contrib/back-ldif/back-ldif.h
index 74b2461..b8d6211 100644
--- a/src/contrib/back-ldif/back-ldif.h
+++ b/src/contrib/back-ldif/back-ldif.h
@@ -83,7 +83,6 @@ int ldif_back_unbind(Slapi_PBlock *);
 
 int ldif_back_start(Slapi_PBlock *);
 void ldif_back_close(Slapi_PBlock *);
-void ldif_back_flush(Slapi_PBlock *);
 void ldif_free_db(LDIF *);
 
 int ldif_back_compare(Slapi_PBlock *);
diff --git a/src/contrib/back-ldif/close.c b/src/contrib/back-ldif/close.c
index bf9c7d2..ce566b7 100644
--- a/src/contrib/back-ldif/close.c
+++ b/src/contrib/back-ldif/close.c
@@ -67,18 +67,3 @@ ldif_back_close(Slapi_PBlock *pb)
     ldif_free_db(db);
     slapi_log_err(SLAPI_LOG_TRACE, "ldif backend done syncing\n", 0, 0, 0);
 }
-
-/*
- *  Function: ldif_back_flush
- *
- *  Returns: void
- *
- *  Description: does nothing
- */
-void
-ldif_back_flush(Slapi_PBlock *pb)
-{
-    slapi_log_err(SLAPI_LOG_TRACE, "ldif backend flushing\n", 0, 0, 0);
-    slapi_log_err(SLAPI_LOG_TRACE, "ldif backend done flushing\n", 0, 0, 0);
-    return;
-}
diff --git a/src/contrib/back-ldif/init.c b/src/contrib/back-ldif/init.c
index 77fbcad..dbbd6f8 100644
--- a/src/contrib/back-ldif/init.c
+++ b/src/contrib/back-ldif/init.c
@@ -97,8 +97,6 @@ ldif_back_init(Slapi_PBlock *pb)
                            (void *)ldif_back_config);
     rc |= slapi_pblock_set(pb, SLAPI_PLUGIN_CLOSE_FN,
                            (void *)ldif_back_close);
-    rc |= slapi_pblock_set(pb, SLAPI_PLUGIN_DB_FLUSH_FN,
-                           (void *)ldif_back_flush);
     rc |= slapi_pblock_set(pb, SLAPI_PLUGIN_START_FN,
                            (void *)ldif_back_start);
     if (rc != 0) {
diff --git a/test/libslapd/pblock/pblock_accessors.txt b/test/libslapd/pblock/pblock_accessors.txt
index 8a4805d..93e4864 100644
--- a/test/libslapd/pblock/pblock_accessors.txt
+++ b/test/libslapd/pblock/pblock_accessors.txt
@@ -151,7 +151,6 @@ SLAPI_PLUGIN_DB_DBVERIFY_FN
 SLAPI_PLUGIN_DB_DELETE_FN
 SLAPI_PLUGIN_DB_ENTRY_FN
 SLAPI_PLUGIN_DB_ENTRY_RELEASE_FN
-SLAPI_PLUGIN_DB_FLUSH_FN
 SLAPI_PLUGIN_DB_GET_INFO_FN
 SLAPI_PLUGIN_DB_INIT_INSTANCE_FN
 SLAPI_PLUGIN_DB_LDIF2DB_FN
diff --git a/test/libslapd/pblock/pblock_accessors_freq.txt b/test/libslapd/pblock/pblock_accessors_freq.txt
index cb3b5ef..e332d9b 100644
--- a/test/libslapd/pblock/pblock_accessors_freq.txt
+++ b/test/libslapd/pblock/pblock_accessors_freq.txt
@@ -304,8 +304,6 @@ SLAPI_PLUGIN_DB_ENTRY_FN
 7
 SLAPI_PLUGIN_DB_ENTRY_RELEASE_FN
 9
-SLAPI_PLUGIN_DB_FLUSH_FN
-10
 SLAPI_PLUGIN_DB_GET_INFO_FN
 6
 SLAPI_PLUGIN_DB_INIT_INSTANCE_FN
-- 
2.5.5

