]> git.ipfire.org Git - thirdparty/bind9.git/commitdiff
Replace isc_mem_destroy() with isc_mem_detach()
authorOndřej Surý <ondrej@isc.org>
Mon, 9 Sep 2024 11:38:31 +0000 (13:38 +0200)
committerOndřej Surý <ondrej@isc.org>
Wed, 5 Mar 2025 10:17:17 +0000 (11:17 +0100)
Remove legacy isc_mem_destroy() and just use isc_mem_detach() as
isc_mem_destroy() doesn't play well with call_rcu API.

34 files changed:
bin/check/named-checkconf.c
bin/check/named-checkzone.c
bin/confgen/rndc-confgen.c
bin/confgen/tsig-keygen.c
bin/dnssec/dnssec-cds.c
bin/dnssec/dnssec-dsfromkey.c
bin/dnssec/dnssec-importkey.c
bin/dnssec/dnssec-keyfromlabel.c
bin/dnssec/dnssec-keygen.c
bin/dnssec/dnssec-revoke.c
bin/dnssec/dnssec-settime.c
bin/dnssec/dnssec-verify.c
bin/tests/system/makejournal.c
bin/tests/system/rsabigexponent/bigkey.c
bin/tests/wire_test.c
bin/tools/dnstap-read.c
bin/tools/named-rrchecker.c
doc/misc/cfg_test.c
fuzz/dns_master_load.c
fuzz/dns_qp.c
fuzz/dns_rdata_fromtext.c
lib/dns/dst_api.c
lib/isc/crypto.c
lib/isc/include/isc/mem.h
lib/isc/managers.c
lib/isc/mem.c
lib/isc/uv.c
lib/isc/xml.c
tests/bench/compress.c
tests/bench/qpmulti.c
tests/dns/qpdb_test.c
tests/include/tests/isc.h
tests/isc/mem_test.c
tests/libtest/isc.c

index e0210cfbd382a8f8ff1add01de087a721338c17d..abdd78e8e49a6f9aadcf6818d5c76daecb5a4fcc 100644 (file)
@@ -761,7 +761,7 @@ cleanup:
        }
 
        if (mctx != NULL) {
-               isc_mem_destroy(&mctx);
+               isc_mem_detach(&mctx);
        }
 
        return result == ISC_R_SUCCESS ? 0 : 1;
index 998171662cc5a332603854f50de569f62111fe9e..fb49f842d6dea3f1cd0742050f4fa5f5be17f9b4 100644 (file)
@@ -577,7 +577,7 @@ main(int argc, char **argv) {
                fprintf(errout, "OK\n");
        }
        destroy();
-       isc_mem_destroy(&mctx);
+       isc_mem_detach(&mctx);
 
        return (result == ISC_R_SUCCESS) ? 0 : 1;
 }
index a6526268b4df64c22043eeb5c1d335d5cd9e9b0e..6f6fce391393b67bb279b8d9904bac514783b360 100644 (file)
@@ -290,7 +290,7 @@ options {\n\
                isc_mem_stats(mctx, stderr);
        }
 
-       isc_mem_destroy(&mctx);
+       isc_mem_detach(&mctx);
 
        return 0;
 }
index ee6470d9e9bf03b76fabe4b83d8c514da2887105..ff0195b97b86974722760012099ec58c3f9e86e3 100644 (file)
@@ -296,7 +296,7 @@ nsupdate -k <keyfile>\n");
                isc_mem_stats(mctx, stderr);
        }
 
-       isc_mem_destroy(&mctx);
+       isc_mem_detach(&mctx);
 
        return 0;
 }
index 13368126ef1dbfb55f9902a1efab7dd60568028e..d4993051d9eff630fffd69a0d691ab7a704da314 100644 (file)
@@ -1075,7 +1075,7 @@ cleanup(void) {
                if (print_mem_stats && verbose > 10) {
                        isc_mem_stats(mctx, stdout);
                }
-               isc_mem_destroy(&mctx);
+               isc_mem_detach(&mctx);
        }
 }
 
index 9647638eac7451625e670efa65197de4554b90ab..c5c5c4d4178a1259cae5a47af4295f737a6b2855 100644 (file)
@@ -543,7 +543,7 @@ main(int argc, char **argv) {
        if (verbose > 10) {
                isc_mem_stats(mctx, stdout);
        }
-       isc_mem_destroy(&mctx);
+       isc_mem_detach(&mctx);
 
        fflush(stdout);
        if (ferror(stdout)) {
index 3d5ca6724e340568dc87976ac77130d3bf565711..7ad8a144285bed5525d92531333e371aa714b1f1 100644 (file)
@@ -456,7 +456,7 @@ main(int argc, char **argv) {
        if (verbose > 10) {
                isc_mem_stats(mctx, stdout);
        }
-       isc_mem_destroy(&mctx);
+       isc_mem_detach(&mctx);
 
        fflush(stdout);
        if (ferror(stdout)) {
index dadf6e0c9bb88f08d5b3a29c6226300d240f6eef..b8289358b2f545dacf0aa6c393d1a0c7825995ad 100644 (file)
@@ -746,7 +746,7 @@ main(int argc, char **argv) {
                isc_mem_stats(mctx, stdout);
        }
        isc_mem_free(mctx, label);
-       isc_mem_destroy(&mctx);
+       isc_mem_detach(&mctx);
 
        if (freeit != NULL) {
                free(freeit);
index adc98f07be41f4d8304116d28e963a316c8c531d..93d9d693a9079b030248747e656d5b1b1523e6d4 100644 (file)
@@ -1280,7 +1280,7 @@ main(int argc, char **argv) {
        if (verbose > 10) {
                isc_mem_stats(mctx, stdout);
        }
-       isc_mem_destroy(&mctx);
+       isc_mem_detach(&mctx);
 
        if (freeit != NULL) {
                free(freeit);
index 5f54ad297cf5edeb366095a94ae4f35226c80551..8c647fefd625e71f876482f35840254e05f8cf54 100644 (file)
@@ -248,7 +248,7 @@ cleanup:
        if (dir != NULL) {
                isc_mem_free(mctx, dir);
        }
-       isc_mem_destroy(&mctx);
+       isc_mem_detach(&mctx);
 
        return 0;
 }
index 7f14e0fc38bbfe90fa3e03e5b256fec7fa45dfa4..cb99e54066f57bb61401c30dfd265d3bd404bca1 100644 (file)
@@ -949,7 +949,7 @@ main(int argc, char **argv) {
                isc_mem_stats(mctx, stdout);
        }
        isc_mem_free(mctx, directory);
-       isc_mem_destroy(&mctx);
+       isc_mem_detach(&mctx);
 
        return 0;
 }
index 1b00812c64c153bd24fc0b2684a22760cd03d9c1..cd2943122356f6178e60d5fcc36e6414360d3f3e 100644 (file)
@@ -330,7 +330,7 @@ main(int argc, char *argv[]) {
        if (verbose > 10) {
                isc_mem_stats(mctx, stdout);
        }
-       isc_mem_destroy(&mctx);
+       isc_mem_detach(&mctx);
 
        return result == ISC_R_SUCCESS ? 0 : 1;
 }
index 94a92b9a7376e13b3ceb386d45b1256aa558f41b..eb85ad25a5ad59938ea2ffe27f59a6d0da1b904c 100644 (file)
@@ -111,7 +111,7 @@ cleanup:
        }
 
        if (mctx != NULL) {
-               isc_mem_destroy(&mctx);
+               isc_mem_detach(&mctx);
        }
 
        return result != ISC_R_SUCCESS ? 1 : 0;
index 2ae0f3dec09d0992c972023d511c2540b39cfe49..57072297d048bcc254fa62aab58281c88129c058 100644 (file)
@@ -140,7 +140,7 @@ main(int argc, char **argv) {
        printf("%s\n", filename);
        dst_key_free(&key);
 
-       isc_mem_destroy(&mctx);
+       isc_mem_detach(&mctx);
        return 0;
 }
 
index bf130c7fc3c90e8c3b2adc8214d77f7a9e2139cd..ec0ecccf5e044a9aa4f063a8c5672f3bb7bbb73f 100644 (file)
@@ -260,7 +260,7 @@ main(int argc, char *argv[]) {
        if (printmemstats) {
                isc_mem_stats(mctx, stdout);
        }
-       isc_mem_destroy(&mctx);
+       isc_mem_detach(&mctx);
 
        return 0;
 }
index 501d70ad96d5f6e675d3cb569143bb23eb39d2a5..c9e5406fc389af9efc6b416dccbe34ddbfc82d2c 100644 (file)
@@ -425,7 +425,7 @@ cleanup:
        if (message != NULL) {
                dns_message_detach(&message);
        }
-       isc_mem_destroy(&mctx);
+       isc_mem_detach(&mctx);
 
        exit(rv);
 }
index 2de1d31bf86e4dae966e8303d254e92f8a07005d..9772bb1a8d30036ab1bc53444cf4aea876992a7f 100644 (file)
@@ -61,7 +61,7 @@ cleanup(void) {
                isc_lex_destroy(&lex);
        }
        if (mctx != NULL) {
-               isc_mem_destroy(&mctx);
+               isc_mem_detach(&mctx);
        }
 }
 
index 64c64d27000b9742c9e9ceef4996c6da377ee28e..9a26acc194498b55db135d9618aa41085e73bd43 100644 (file)
@@ -154,7 +154,7 @@ main(int argc, char **argv) {
        if (memstats) {
                isc_mem_stats(mctx, stderr);
        }
-       isc_mem_destroy(&mctx);
+       isc_mem_detach(&mctx);
 
        fflush(stdout);
        if (ferror(stdout)) {
index 1acd4c816a86168f398918be3dcf39355dceeeb6..09717329fa5494a5bd7ebcb29a435dc1516e0ca3 100644 (file)
@@ -74,6 +74,6 @@ LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) {
 
 end:
        dns_db_detach(&db);
-       isc_mem_destroy(&mctx);
+       isc_mem_detach(&mctx);
        return 0;
 }
index 1077013bfa19a0ef8165cdafd7574ea1319e4ec6..8b9fc08a6e8b92d3297d8e9e0d364861dc2e94d4 100644 (file)
@@ -211,7 +211,7 @@ LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) {
        }
 
        dns_qp_destroy(&qp);
-       isc_mem_destroy(&mctx);
+       isc_mem_detach(&mctx);
        isc_mem_checkdestroyed(stderr);
 
        for (size_t i = 0; i < ARRAY_SIZE(item); i++) {
index ecdcb3faca36140b5ca6d02c9057bd040eb7da0a..24d3788dfe87c05ad435644f9d172c37c3500e2f 100644 (file)
@@ -145,6 +145,6 @@ LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) {
 cleanup:
        isc_lex_close(lex);
        isc_lex_destroy(&lex);
-       isc_mem_destroy(&mctx);
+       isc_mem_detach(&mctx);
        return 0;
 }
index 6446de1f6af0ac01f228ca5e5d23c64ef369876a..3f844264c661ee2c5945b727e1766d6bfff1b0b9 100644 (file)
@@ -226,7 +226,7 @@ dst__lib_shutdown(void) {
                }
        }
 
-       isc_mem_destroy(&dst__mctx);
+       isc_mem_detach(&dst__mctx);
 }
 
 bool
index 209f49e90c4de83be8472323f2b27ccfbd7485b0..c99592befc390e56801eacfe7d64d1732e85cd7b 100644 (file)
@@ -314,5 +314,5 @@ isc__crypto_shutdown(void) {
 
        OPENSSL_cleanup();
 
-       isc_mem_destroy(&isc__crypto_mctx);
+       isc_mem_detach(&isc__crypto_mctx);
 }
index 28bdd64041e410a9a55e9e69a6c62118144b1c9c..ad3b4bd97a8a25f450f96d64805b20b41a0d85c6 100644 (file)
@@ -272,13 +272,6 @@ isc__mem_detach(isc_mem_t **_ISC_MEM_FLARG);
  */
 /*@}*/
 
-#define isc_mem_destroy(cp) isc__mem_destroy((cp)_ISC_MEM_FILELINE)
-void
-isc__mem_destroy(isc_mem_t **_ISC_MEM_FLARG);
-/*%<
- * Destroy a memory context.
- */
-
 void
 isc_mem_stats(isc_mem_t *mctx, FILE *out);
 /*%<
index 5471122300aaea06d04d1e4cb7489f3c0357e39c..b4912e8ac048dde767e09f51b694ed875f2d4371 100644 (file)
@@ -47,5 +47,5 @@ isc_managers_destroy(isc_mem_t **mctxp, isc_loopmgr_t **loopmgrp,
 
        isc_netmgr_destroy(netmgrp);
        isc_loopmgr_destroy(loopmgrp);
-       isc_mem_destroy(mctxp);
+       isc_mem_detach(mctxp);
 }
index 2651c503abaa535c2a4d5ab28d3d96691d7d4deb..4fb27ad23d2c20551d06e4fff041bde2c57057d9 100644 (file)
@@ -598,40 +598,6 @@ isc__mem_putanddetach(isc_mem_t **ctxp, void *ptr, size_t size,
        isc__mem_detach(&ctx FLARG_PASS);
 }
 
-void
-isc__mem_destroy(isc_mem_t **ctxp FLARG) {
-       isc_mem_t *ctx = NULL;
-
-       /*
-        * This routine provides legacy support for callers who use mctxs
-        * without attaching/detaching.
-        */
-
-       REQUIRE(ctxp != NULL && VALID_CONTEXT(*ctxp));
-
-       ctx = *ctxp;
-       *ctxp = NULL;
-
-       rcu_barrier();
-
-#if ISC_MEM_TRACKLINES
-       if ((ctx->debugging & ISC_MEM_DEBUGTRACE) != 0) {
-               fprintf(stderr, "destroy mctx %p file %s line %u\n", ctx, file,
-                       line);
-       }
-
-       if (isc_refcount_decrement(&ctx->references) > 1) {
-               print_active(ctx, stderr);
-       }
-#else  /* if ISC_MEM_TRACKLINES */
-       isc_refcount_decrementz(&ctx->references);
-#endif /* if ISC_MEM_TRACKLINES */
-       isc_refcount_destroy(&ctx->references);
-       destroy(ctx);
-
-       *ctxp = NULL;
-}
-
 void *
 isc__mem_get(isc_mem_t *ctx, size_t size, int flags FLARG) {
        void *ptr = NULL;
index 7ad878cf7fa7735fdba27cd149f3b0c193afd27f..431cecbf483bb73f7e4aa4c3cf529e3f62a54559 100644 (file)
@@ -146,7 +146,7 @@ void
 isc__uv_shutdown(void) {
 #if UV_VERSION_HEX >= UV_VERSION(1, 38, 0)
        uv_library_shutdown();
-       isc_mem_destroy(&isc__uv_mctx);
+       isc_mem_detach(&isc__uv_mctx);
 #endif /* UV_VERSION_HEX < UV_VERSION(1, 38, 0) */
 }
 
index 7dd9424fe5226ea7352b9f9e7bf1e141aa3c826e..cbff418904683b8316d7287602f91fba5ba3cb12 100644 (file)
@@ -64,7 +64,7 @@ void
 isc__xml_shutdown(void) {
 #ifdef HAVE_LIBXML2
        xmlCleanupParser();
-       isc_mem_destroy(&isc__xml_mctx);
+       isc_mem_detach(&isc__xml_mctx);
 #endif /* HAVE_LIBXML2 */
 }
 
index 912e8847e21f8ed20f886227428ce55038095185..f6c51afea182ac2f3dde379d587e3c02276cc44a 100644 (file)
@@ -100,7 +100,7 @@ main(void) {
 
        printf("names %u\n", count);
 
-       isc_mem_destroy(&mctx);
+       isc_mem_detach(&mctx);
 
        return 0;
 }
index 13aded4098a0c5535612f3a9fa39fa18d8b3d43c..d2d5d5f8b7ed21d3d85d0548674207a3e1543980 100644 (file)
@@ -889,7 +889,7 @@ main(void) {
 
        isc_mem_free(mctx, item);
        isc_mem_checkdestroyed(stdout);
-       isc_mem_destroy(&mctx);
+       isc_mem_detach(&mctx);
 
        return 0;
 }
index 73931889dfce7ebfac27c3a76794e10962f6f06c..24101becb9aadc4e391f67c8add25e208508d57e 100644 (file)
@@ -158,7 +158,7 @@ ISC_LOOP_TEST_IMPL(overmempurge_bigrdata) {
        }
 
        dns_db_detach(&db);
-       isc_mem_destroy(&mctx2);
+       isc_mem_detach(&mctx2);
        isc_loopmgr_shutdown(loopmgr);
 }
 
@@ -208,7 +208,7 @@ ISC_LOOP_TEST_IMPL(overmempurge_longname) {
        }
 
        dns_db_detach(&db);
-       isc_mem_destroy(&mctx2);
+       isc_mem_detach(&mctx2);
        isc_loopmgr_shutdown(loopmgr);
 }
 
index b49b50951838ddb81e399449afcd3474432c9287..a7464d8019cd06b1499ab49d2c591d755b10366c 100644 (file)
@@ -249,7 +249,7 @@ teardown_managers(void **state);
                        r = cmocka_run_group_tests(tests, setup, teardown);             \
                }                                                                       \
                                                                                         \
-               isc_mem_destroy(&mctx);                                                 \
+               isc_mem_detach(&mctx);                                                  \
                                                                                         \
                return (r);                                                             \
        }
index ddb655440de8a5be0e7e38d85fd7b6e77b0b3642..aaf94c0d7757b76862fa588bd9779306947d42f5 100644 (file)
@@ -197,7 +197,7 @@ ISC_RUN_TEST_IMPL(isc_mem_inuse) {
 
        assert_int_equal(diff, 0);
 
-       isc_mem_destroy(&mctx2);
+       isc_mem_detach(&mctx2);
 }
 
 ISC_RUN_TEST_IMPL(isc_mem_zeroget) {
@@ -323,7 +323,7 @@ ISC_RUN_TEST_IMPL(isc_mem_overmem) {
        isc_mem_free(omctx, data1);
        assert_false(isc_mem_isovermem(omctx));
 
-       isc_mem_destroy(&omctx);
+       isc_mem_detach(&omctx);
 }
 
 #if ISC_MEM_TRACKLINES
@@ -345,7 +345,7 @@ ISC_RUN_TEST_IMPL(isc_mem_noflags) {
        assert_non_null(ptr);
        isc__mem_printactive(mctx2, f);
        isc_mem_put(mctx2, ptr, 2048);
-       isc_mem_destroy(&mctx2);
+       isc_mem_detach(&mctx2);
        isc_mem_debugging = ISC_MEM_DEBUGRECORD;
        isc_stdio_close(f);
 
@@ -379,7 +379,7 @@ ISC_RUN_TEST_IMPL(isc_mem_recordflag) {
        assert_non_null(ptr);
        isc__mem_printactive(mctx2, f);
        isc_mem_put(mctx2, ptr, 2048);
-       isc_mem_destroy(&mctx2);
+       isc_mem_detach(&mctx2);
        isc_stdio_close(f);
 
        memset(buf, 0, sizeof(buf));
@@ -419,7 +419,7 @@ ISC_RUN_TEST_IMPL(isc_mem_traceflag) {
        assert_non_null(ptr);
        isc__mem_printactive(mctx2, f);
        isc_mem_put(mctx2, ptr, 2048);
-       isc_mem_destroy(&mctx2);
+       isc_mem_detach(&mctx2);
        isc_mem_debugging = ISC_MEM_DEBUGRECORD;
        isc_stdio_close(f);
 
index c53cfff24b0ce1e85ce971b142230800292fdd5c..92a3d8afac482b31ebfdcd3cd67bb3a3327bc62e 100644 (file)
@@ -79,7 +79,7 @@ setup_mctx(void **state ISC_ATTR_UNUSED) {
 
 int
 teardown_mctx(void **state ISC_ATTR_UNUSED) {
-       isc_mem_destroy(&mctx);
+       isc_mem_detach(&mctx);
 
        return 0;
 }