mirror of
https://gitlab.isc.org/isc-projects/bind9.git
synced 2025-04-18 09:44:09 +03:00
Replace isc_mem_destroy() with isc_mem_detach()
Remove legacy isc_mem_destroy() and just use isc_mem_detach() as isc_mem_destroy() doesn't play well with call_rcu API.
This commit is contained in:
parent
f28020265c
commit
552cf64a70
@ -761,7 +761,7 @@ cleanup:
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (mctx != NULL) {
|
if (mctx != NULL) {
|
||||||
isc_mem_destroy(&mctx);
|
isc_mem_detach(&mctx);
|
||||||
}
|
}
|
||||||
|
|
||||||
return result == ISC_R_SUCCESS ? 0 : 1;
|
return result == ISC_R_SUCCESS ? 0 : 1;
|
||||||
|
@ -577,7 +577,7 @@ main(int argc, char **argv) {
|
|||||||
fprintf(errout, "OK\n");
|
fprintf(errout, "OK\n");
|
||||||
}
|
}
|
||||||
destroy();
|
destroy();
|
||||||
isc_mem_destroy(&mctx);
|
isc_mem_detach(&mctx);
|
||||||
|
|
||||||
return (result == ISC_R_SUCCESS) ? 0 : 1;
|
return (result == ISC_R_SUCCESS) ? 0 : 1;
|
||||||
}
|
}
|
||||||
|
@ -290,7 +290,7 @@ options {\n\
|
|||||||
isc_mem_stats(mctx, stderr);
|
isc_mem_stats(mctx, stderr);
|
||||||
}
|
}
|
||||||
|
|
||||||
isc_mem_destroy(&mctx);
|
isc_mem_detach(&mctx);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@ -296,7 +296,7 @@ nsupdate -k <keyfile>\n");
|
|||||||
isc_mem_stats(mctx, stderr);
|
isc_mem_stats(mctx, stderr);
|
||||||
}
|
}
|
||||||
|
|
||||||
isc_mem_destroy(&mctx);
|
isc_mem_detach(&mctx);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@ -1075,7 +1075,7 @@ cleanup(void) {
|
|||||||
if (print_mem_stats && verbose > 10) {
|
if (print_mem_stats && verbose > 10) {
|
||||||
isc_mem_stats(mctx, stdout);
|
isc_mem_stats(mctx, stdout);
|
||||||
}
|
}
|
||||||
isc_mem_destroy(&mctx);
|
isc_mem_detach(&mctx);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -543,7 +543,7 @@ main(int argc, char **argv) {
|
|||||||
if (verbose > 10) {
|
if (verbose > 10) {
|
||||||
isc_mem_stats(mctx, stdout);
|
isc_mem_stats(mctx, stdout);
|
||||||
}
|
}
|
||||||
isc_mem_destroy(&mctx);
|
isc_mem_detach(&mctx);
|
||||||
|
|
||||||
fflush(stdout);
|
fflush(stdout);
|
||||||
if (ferror(stdout)) {
|
if (ferror(stdout)) {
|
||||||
|
@ -456,7 +456,7 @@ main(int argc, char **argv) {
|
|||||||
if (verbose > 10) {
|
if (verbose > 10) {
|
||||||
isc_mem_stats(mctx, stdout);
|
isc_mem_stats(mctx, stdout);
|
||||||
}
|
}
|
||||||
isc_mem_destroy(&mctx);
|
isc_mem_detach(&mctx);
|
||||||
|
|
||||||
fflush(stdout);
|
fflush(stdout);
|
||||||
if (ferror(stdout)) {
|
if (ferror(stdout)) {
|
||||||
|
@ -746,7 +746,7 @@ main(int argc, char **argv) {
|
|||||||
isc_mem_stats(mctx, stdout);
|
isc_mem_stats(mctx, stdout);
|
||||||
}
|
}
|
||||||
isc_mem_free(mctx, label);
|
isc_mem_free(mctx, label);
|
||||||
isc_mem_destroy(&mctx);
|
isc_mem_detach(&mctx);
|
||||||
|
|
||||||
if (freeit != NULL) {
|
if (freeit != NULL) {
|
||||||
free(freeit);
|
free(freeit);
|
||||||
|
@ -1280,7 +1280,7 @@ main(int argc, char **argv) {
|
|||||||
if (verbose > 10) {
|
if (verbose > 10) {
|
||||||
isc_mem_stats(mctx, stdout);
|
isc_mem_stats(mctx, stdout);
|
||||||
}
|
}
|
||||||
isc_mem_destroy(&mctx);
|
isc_mem_detach(&mctx);
|
||||||
|
|
||||||
if (freeit != NULL) {
|
if (freeit != NULL) {
|
||||||
free(freeit);
|
free(freeit);
|
||||||
|
@ -248,7 +248,7 @@ cleanup:
|
|||||||
if (dir != NULL) {
|
if (dir != NULL) {
|
||||||
isc_mem_free(mctx, dir);
|
isc_mem_free(mctx, dir);
|
||||||
}
|
}
|
||||||
isc_mem_destroy(&mctx);
|
isc_mem_detach(&mctx);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@ -949,7 +949,7 @@ main(int argc, char **argv) {
|
|||||||
isc_mem_stats(mctx, stdout);
|
isc_mem_stats(mctx, stdout);
|
||||||
}
|
}
|
||||||
isc_mem_free(mctx, directory);
|
isc_mem_free(mctx, directory);
|
||||||
isc_mem_destroy(&mctx);
|
isc_mem_detach(&mctx);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@ -330,7 +330,7 @@ main(int argc, char *argv[]) {
|
|||||||
if (verbose > 10) {
|
if (verbose > 10) {
|
||||||
isc_mem_stats(mctx, stdout);
|
isc_mem_stats(mctx, stdout);
|
||||||
}
|
}
|
||||||
isc_mem_destroy(&mctx);
|
isc_mem_detach(&mctx);
|
||||||
|
|
||||||
return result == ISC_R_SUCCESS ? 0 : 1;
|
return result == ISC_R_SUCCESS ? 0 : 1;
|
||||||
}
|
}
|
||||||
|
@ -111,7 +111,7 @@ cleanup:
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (mctx != NULL) {
|
if (mctx != NULL) {
|
||||||
isc_mem_destroy(&mctx);
|
isc_mem_detach(&mctx);
|
||||||
}
|
}
|
||||||
|
|
||||||
return result != ISC_R_SUCCESS ? 1 : 0;
|
return result != ISC_R_SUCCESS ? 1 : 0;
|
||||||
|
@ -140,7 +140,7 @@ main(int argc, char **argv) {
|
|||||||
printf("%s\n", filename);
|
printf("%s\n", filename);
|
||||||
dst_key_free(&key);
|
dst_key_free(&key);
|
||||||
|
|
||||||
isc_mem_destroy(&mctx);
|
isc_mem_detach(&mctx);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -260,7 +260,7 @@ main(int argc, char *argv[]) {
|
|||||||
if (printmemstats) {
|
if (printmemstats) {
|
||||||
isc_mem_stats(mctx, stdout);
|
isc_mem_stats(mctx, stdout);
|
||||||
}
|
}
|
||||||
isc_mem_destroy(&mctx);
|
isc_mem_detach(&mctx);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@ -425,7 +425,7 @@ cleanup:
|
|||||||
if (message != NULL) {
|
if (message != NULL) {
|
||||||
dns_message_detach(&message);
|
dns_message_detach(&message);
|
||||||
}
|
}
|
||||||
isc_mem_destroy(&mctx);
|
isc_mem_detach(&mctx);
|
||||||
|
|
||||||
exit(rv);
|
exit(rv);
|
||||||
}
|
}
|
||||||
|
@ -61,7 +61,7 @@ cleanup(void) {
|
|||||||
isc_lex_destroy(&lex);
|
isc_lex_destroy(&lex);
|
||||||
}
|
}
|
||||||
if (mctx != NULL) {
|
if (mctx != NULL) {
|
||||||
isc_mem_destroy(&mctx);
|
isc_mem_detach(&mctx);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -154,7 +154,7 @@ main(int argc, char **argv) {
|
|||||||
if (memstats) {
|
if (memstats) {
|
||||||
isc_mem_stats(mctx, stderr);
|
isc_mem_stats(mctx, stderr);
|
||||||
}
|
}
|
||||||
isc_mem_destroy(&mctx);
|
isc_mem_detach(&mctx);
|
||||||
|
|
||||||
fflush(stdout);
|
fflush(stdout);
|
||||||
if (ferror(stdout)) {
|
if (ferror(stdout)) {
|
||||||
|
@ -74,6 +74,6 @@ LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) {
|
|||||||
|
|
||||||
end:
|
end:
|
||||||
dns_db_detach(&db);
|
dns_db_detach(&db);
|
||||||
isc_mem_destroy(&mctx);
|
isc_mem_detach(&mctx);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@ -211,7 +211,7 @@ LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
dns_qp_destroy(&qp);
|
dns_qp_destroy(&qp);
|
||||||
isc_mem_destroy(&mctx);
|
isc_mem_detach(&mctx);
|
||||||
isc_mem_checkdestroyed(stderr);
|
isc_mem_checkdestroyed(stderr);
|
||||||
|
|
||||||
for (size_t i = 0; i < ARRAY_SIZE(item); i++) {
|
for (size_t i = 0; i < ARRAY_SIZE(item); i++) {
|
||||||
|
@ -145,6 +145,6 @@ LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) {
|
|||||||
cleanup:
|
cleanup:
|
||||||
isc_lex_close(lex);
|
isc_lex_close(lex);
|
||||||
isc_lex_destroy(&lex);
|
isc_lex_destroy(&lex);
|
||||||
isc_mem_destroy(&mctx);
|
isc_mem_detach(&mctx);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@ -226,7 +226,7 @@ dst__lib_shutdown(void) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
isc_mem_destroy(&dst__mctx);
|
isc_mem_detach(&dst__mctx);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool
|
bool
|
||||||
|
@ -314,5 +314,5 @@ isc__crypto_shutdown(void) {
|
|||||||
|
|
||||||
OPENSSL_cleanup();
|
OPENSSL_cleanup();
|
||||||
|
|
||||||
isc_mem_destroy(&isc__crypto_mctx);
|
isc_mem_detach(&isc__crypto_mctx);
|
||||||
}
|
}
|
||||||
|
@ -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
|
void
|
||||||
isc_mem_stats(isc_mem_t *mctx, FILE *out);
|
isc_mem_stats(isc_mem_t *mctx, FILE *out);
|
||||||
/*%<
|
/*%<
|
||||||
|
@ -47,5 +47,5 @@ isc_managers_destroy(isc_mem_t **mctxp, isc_loopmgr_t **loopmgrp,
|
|||||||
|
|
||||||
isc_netmgr_destroy(netmgrp);
|
isc_netmgr_destroy(netmgrp);
|
||||||
isc_loopmgr_destroy(loopmgrp);
|
isc_loopmgr_destroy(loopmgrp);
|
||||||
isc_mem_destroy(mctxp);
|
isc_mem_detach(mctxp);
|
||||||
}
|
}
|
||||||
|
@ -598,40 +598,6 @@ isc__mem_putanddetach(isc_mem_t **ctxp, void *ptr, size_t size,
|
|||||||
isc__mem_detach(&ctx FLARG_PASS);
|
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 *
|
void *
|
||||||
isc__mem_get(isc_mem_t *ctx, size_t size, int flags FLARG) {
|
isc__mem_get(isc_mem_t *ctx, size_t size, int flags FLARG) {
|
||||||
void *ptr = NULL;
|
void *ptr = NULL;
|
||||||
|
@ -146,7 +146,7 @@ void
|
|||||||
isc__uv_shutdown(void) {
|
isc__uv_shutdown(void) {
|
||||||
#if UV_VERSION_HEX >= UV_VERSION(1, 38, 0)
|
#if UV_VERSION_HEX >= UV_VERSION(1, 38, 0)
|
||||||
uv_library_shutdown();
|
uv_library_shutdown();
|
||||||
isc_mem_destroy(&isc__uv_mctx);
|
isc_mem_detach(&isc__uv_mctx);
|
||||||
#endif /* UV_VERSION_HEX < UV_VERSION(1, 38, 0) */
|
#endif /* UV_VERSION_HEX < UV_VERSION(1, 38, 0) */
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -64,7 +64,7 @@ void
|
|||||||
isc__xml_shutdown(void) {
|
isc__xml_shutdown(void) {
|
||||||
#ifdef HAVE_LIBXML2
|
#ifdef HAVE_LIBXML2
|
||||||
xmlCleanupParser();
|
xmlCleanupParser();
|
||||||
isc_mem_destroy(&isc__xml_mctx);
|
isc_mem_detach(&isc__xml_mctx);
|
||||||
#endif /* HAVE_LIBXML2 */
|
#endif /* HAVE_LIBXML2 */
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -100,7 +100,7 @@ main(void) {
|
|||||||
|
|
||||||
printf("names %u\n", count);
|
printf("names %u\n", count);
|
||||||
|
|
||||||
isc_mem_destroy(&mctx);
|
isc_mem_detach(&mctx);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@ -889,7 +889,7 @@ main(void) {
|
|||||||
|
|
||||||
isc_mem_free(mctx, item);
|
isc_mem_free(mctx, item);
|
||||||
isc_mem_checkdestroyed(stdout);
|
isc_mem_checkdestroyed(stdout);
|
||||||
isc_mem_destroy(&mctx);
|
isc_mem_detach(&mctx);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@ -158,7 +158,7 @@ ISC_LOOP_TEST_IMPL(overmempurge_bigrdata) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
dns_db_detach(&db);
|
dns_db_detach(&db);
|
||||||
isc_mem_destroy(&mctx2);
|
isc_mem_detach(&mctx2);
|
||||||
isc_loopmgr_shutdown(loopmgr);
|
isc_loopmgr_shutdown(loopmgr);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -208,7 +208,7 @@ ISC_LOOP_TEST_IMPL(overmempurge_longname) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
dns_db_detach(&db);
|
dns_db_detach(&db);
|
||||||
isc_mem_destroy(&mctx2);
|
isc_mem_detach(&mctx2);
|
||||||
isc_loopmgr_shutdown(loopmgr);
|
isc_loopmgr_shutdown(loopmgr);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -249,7 +249,7 @@ teardown_managers(void **state);
|
|||||||
r = cmocka_run_group_tests(tests, setup, teardown); \
|
r = cmocka_run_group_tests(tests, setup, teardown); \
|
||||||
} \
|
} \
|
||||||
\
|
\
|
||||||
isc_mem_destroy(&mctx); \
|
isc_mem_detach(&mctx); \
|
||||||
\
|
\
|
||||||
return (r); \
|
return (r); \
|
||||||
}
|
}
|
||||||
|
@ -197,7 +197,7 @@ ISC_RUN_TEST_IMPL(isc_mem_inuse) {
|
|||||||
|
|
||||||
assert_int_equal(diff, 0);
|
assert_int_equal(diff, 0);
|
||||||
|
|
||||||
isc_mem_destroy(&mctx2);
|
isc_mem_detach(&mctx2);
|
||||||
}
|
}
|
||||||
|
|
||||||
ISC_RUN_TEST_IMPL(isc_mem_zeroget) {
|
ISC_RUN_TEST_IMPL(isc_mem_zeroget) {
|
||||||
@ -323,7 +323,7 @@ ISC_RUN_TEST_IMPL(isc_mem_overmem) {
|
|||||||
isc_mem_free(omctx, data1);
|
isc_mem_free(omctx, data1);
|
||||||
assert_false(isc_mem_isovermem(omctx));
|
assert_false(isc_mem_isovermem(omctx));
|
||||||
|
|
||||||
isc_mem_destroy(&omctx);
|
isc_mem_detach(&omctx);
|
||||||
}
|
}
|
||||||
|
|
||||||
#if ISC_MEM_TRACKLINES
|
#if ISC_MEM_TRACKLINES
|
||||||
@ -345,7 +345,7 @@ ISC_RUN_TEST_IMPL(isc_mem_noflags) {
|
|||||||
assert_non_null(ptr);
|
assert_non_null(ptr);
|
||||||
isc__mem_printactive(mctx2, f);
|
isc__mem_printactive(mctx2, f);
|
||||||
isc_mem_put(mctx2, ptr, 2048);
|
isc_mem_put(mctx2, ptr, 2048);
|
||||||
isc_mem_destroy(&mctx2);
|
isc_mem_detach(&mctx2);
|
||||||
isc_mem_debugging = ISC_MEM_DEBUGRECORD;
|
isc_mem_debugging = ISC_MEM_DEBUGRECORD;
|
||||||
isc_stdio_close(f);
|
isc_stdio_close(f);
|
||||||
|
|
||||||
@ -379,7 +379,7 @@ ISC_RUN_TEST_IMPL(isc_mem_recordflag) {
|
|||||||
assert_non_null(ptr);
|
assert_non_null(ptr);
|
||||||
isc__mem_printactive(mctx2, f);
|
isc__mem_printactive(mctx2, f);
|
||||||
isc_mem_put(mctx2, ptr, 2048);
|
isc_mem_put(mctx2, ptr, 2048);
|
||||||
isc_mem_destroy(&mctx2);
|
isc_mem_detach(&mctx2);
|
||||||
isc_stdio_close(f);
|
isc_stdio_close(f);
|
||||||
|
|
||||||
memset(buf, 0, sizeof(buf));
|
memset(buf, 0, sizeof(buf));
|
||||||
@ -419,7 +419,7 @@ ISC_RUN_TEST_IMPL(isc_mem_traceflag) {
|
|||||||
assert_non_null(ptr);
|
assert_non_null(ptr);
|
||||||
isc__mem_printactive(mctx2, f);
|
isc__mem_printactive(mctx2, f);
|
||||||
isc_mem_put(mctx2, ptr, 2048);
|
isc_mem_put(mctx2, ptr, 2048);
|
||||||
isc_mem_destroy(&mctx2);
|
isc_mem_detach(&mctx2);
|
||||||
isc_mem_debugging = ISC_MEM_DEBUGRECORD;
|
isc_mem_debugging = ISC_MEM_DEBUGRECORD;
|
||||||
isc_stdio_close(f);
|
isc_stdio_close(f);
|
||||||
|
|
||||||
|
@ -79,7 +79,7 @@ setup_mctx(void **state ISC_ATTR_UNUSED) {
|
|||||||
|
|
||||||
int
|
int
|
||||||
teardown_mctx(void **state ISC_ATTR_UNUSED) {
|
teardown_mctx(void **state ISC_ATTR_UNUSED) {
|
||||||
isc_mem_destroy(&mctx);
|
isc_mem_detach(&mctx);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user