]> git.ozlabs.org Git - ccan/blobdiff - ccan/tdb2/tdb1_open.c
tdb2: Remove unused tdb1 functions.
[ccan] / ccan / tdb2 / tdb1_open.c
index e7dbddd9ddbc4b67ed785e6d27bebdaae1270bff..7b548c1d05da11c43c362f120c5ff66aa3ac66b8 100644 (file)
@@ -495,115 +495,3 @@ _PUBLIC_ int tdb1_close(struct tdb1_context *tdb)
 
        return ret;
 }
-
-/* register a loging function */
-_PUBLIC_ void tdb1_set_logging_function(struct tdb1_context *tdb,
-                                       const struct tdb1_logging_context *log_ctx)
-{
-        tdb->log = *log_ctx;
-}
-
-_PUBLIC_ void *tdb1_get_logging_private(struct tdb1_context *tdb)
-{
-       return tdb->log.log_private;
-}
-
-static int tdb1_reopen_internal(struct tdb1_context *tdb, bool active_lock)
-{
-#if !defined(LIBREPLACE_PREAD_NOT_REPLACED) || \
-       !defined(LIBREPLACE_PWRITE_NOT_REPLACED)
-       struct stat st;
-#endif
-
-       if (tdb->flags & TDB1_INTERNAL) {
-               return 0; /* Nothing to do. */
-       }
-
-       if (tdb1_have_extra_locks(tdb)) {
-               TDB1_LOG((tdb, TDB1_DEBUG_ERROR, "tdb1_reopen: reopen not allowed with locks held\n"));
-               goto fail;
-       }
-
-       if (tdb->transaction != 0) {
-               TDB1_LOG((tdb, TDB1_DEBUG_ERROR, "tdb1_reopen: reopen not allowed inside a transaction\n"));
-               goto fail;
-       }
-
-/* If we have real pread & pwrite, we can skip reopen. */
-#if !defined(LIBREPLACE_PREAD_NOT_REPLACED) || \
-       !defined(LIBREPLACE_PWRITE_NOT_REPLACED)
-       if (tdb1_munmap(tdb) != 0) {
-               TDB1_LOG((tdb, TDB1_DEBUG_FATAL, "tdb1_reopen: munmap failed (%s)\n", strerror(errno)));
-               goto fail;
-       }
-       if (close(tdb->fd) != 0)
-               TDB1_LOG((tdb, TDB1_DEBUG_FATAL, "tdb1_reopen: WARNING closing tdb->fd failed!\n"));
-       tdb->fd = open(tdb->name, tdb->open_flags & ~(O_CREAT|O_TRUNC), 0);
-       if (tdb->fd == -1) {
-               TDB1_LOG((tdb, TDB1_DEBUG_FATAL, "tdb1_reopen: open failed (%s)\n", strerror(errno)));
-               goto fail;
-       }
-       if (fstat(tdb->fd, &st) != 0) {
-               TDB1_LOG((tdb, TDB1_DEBUG_FATAL, "tdb1_reopen: fstat failed (%s)\n", strerror(errno)));
-               goto fail;
-       }
-       if (st.st_ino != tdb->inode || st.st_dev != tdb->device) {
-               TDB1_LOG((tdb, TDB1_DEBUG_FATAL, "tdb1_reopen: file dev/inode has changed!\n"));
-               goto fail;
-       }
-       tdb1_mmap(tdb);
-#endif /* fake pread or pwrite */
-
-       /* We may still think we hold the active lock. */
-       tdb->num_lockrecs = 0;
-       SAFE_FREE(tdb->lockrecs);
-
-       if (active_lock && tdb1_nest_lock(tdb, TDB1_ACTIVE_LOCK, F_RDLCK, TDB1_LOCK_WAIT) == -1) {
-               TDB1_LOG((tdb, TDB1_DEBUG_FATAL, "tdb1_reopen: failed to obtain active lock\n"));
-               goto fail;
-       }
-
-       return 0;
-
-fail:
-       tdb1_close(tdb);
-       return -1;
-}
-
-/* reopen a tdb - this can be used after a fork to ensure that we have an independent
-   seek pointer from our parent and to re-establish locks */
-_PUBLIC_ int tdb1_reopen(struct tdb1_context *tdb)
-{
-       return tdb1_reopen_internal(tdb, tdb->flags & TDB1_CLEAR_IF_FIRST);
-}
-
-/* reopen all tdb's */
-_PUBLIC_ int tdb1_reopen_all(int parent_longlived)
-{
-       struct tdb1_context *tdb;
-
-       for (tdb=tdb1s; tdb; tdb = tdb->next) {
-               bool active_lock = (tdb->flags & TDB1_CLEAR_IF_FIRST);
-
-               /*
-                * If the parent is longlived (ie. a
-                * parent daemon architecture), we know
-                * it will keep it's active lock on a
-                * tdb opened with CLEAR_IF_FIRST. Thus
-                * for child processes we don't have to
-                * add an active lock. This is essential
-                * to improve performance on systems that
-                * keep POSIX locks as a non-scalable data
-                * structure in the kernel.
-                */
-               if (parent_longlived) {
-                       /* Ensure no clear-if-first. */
-                       active_lock = false;
-               }
-
-               if (tdb1_reopen_internal(tdb, active_lock) != 0)
-                       return -1;
-       }
-
-       return 0;
-}