From: Alan T. DeKok Date: Tue, 1 Jul 2025 15:44:48 +0000 (-0400) Subject: reset destructor on shutdown X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=ddebfdaac4af2422232cb19ea2eae3674a852df5;p=thirdparty%2Ffreeradius-server.git reset destructor on shutdown --- diff --git a/src/lib/bio/base.c b/src/lib/bio/base.c index f37d2a00a40..5e7a6033e28 100644 --- a/src/lib/bio/base.c +++ b/src/lib/bio/base.c @@ -167,16 +167,14 @@ int fr_bio_shutdown(fr_bio_t *bio) for (/* nothing */; this != NULL; this = fr_bio_next(this)) { my = (fr_bio_common_t *) this; - if (!my->priv_cb.shutdown) continue; - - /* - * The EOF handler said it's NOT at EOF, so we stop processing here. - */ - my->priv_cb.shutdown(&my->bio); - my->priv_cb.shutdown = NULL; + if (my->priv_cb.shutdown) { + my->priv_cb.shutdown(&my->bio); + my->priv_cb.shutdown = NULL; + } my->bio.read = fr_bio_shutdown_read; my->bio.write = fr_bio_shutdown_write; + talloc_set_destructor(my, NULL); } /* diff --git a/src/lib/bio/mem.c b/src/lib/bio/mem.c index 56376e138f5..5829d485b2d 100644 --- a/src/lib/bio/mem.c +++ b/src/lib/bio/mem.c @@ -683,15 +683,6 @@ static int fr_bio_mem_call_verify(fr_bio_t *bio, void *packet_ctx, size_t *size) return -1; } -/* - * The application can read from the BIO until EOF, but cannot write to it. - */ -static void fr_bio_mem_shutdown(fr_bio_t *bio) -{ - bio->read = fr_bio_mem_read_eof; - bio->write = fr_bio_null_write; -} - /** Allocate a memory buffer bio for either reading or writing. */ static bool fr_bio_mem_buf_alloc(fr_bio_mem_t *my, fr_bio_buf_t *buf, size_t size) @@ -784,7 +775,6 @@ fr_bio_t *fr_bio_mem_alloc(TALLOC_CTX *ctx, size_t read_size, size_t write_size, * just doing packet verification/ */ my->priv_cb.eof = fr_bio_mem_eof; - my->priv_cb.shutdown = fr_bio_mem_shutdown; } fr_bio_chain(&my->bio, next); @@ -823,7 +813,6 @@ fr_bio_t *fr_bio_mem_source_alloc(TALLOC_CTX *ctx, size_t write_size, fr_bio_t * /* * @todo - have write pause / write resume callbacks? */ - my->priv_cb.shutdown = fr_bio_mem_shutdown; fr_bio_chain(&my->bio, next);