]> git.ipfire.org Git - thirdparty/freeradius-server.git/commitdiff
on shutdown, set r/w to return new SHUTDOWN error
authorAlan T. DeKok <aland@freeradius.org>
Thu, 26 Jun 2025 20:37:29 +0000 (16:37 -0400)
committerAlan T. DeKok <aland@freeradius.org>
Fri, 27 Jun 2025 18:02:31 +0000 (14:02 -0400)
src/lib/bio/base.c
src/lib/bio/base.h

index f1796386a1cda4cd5b0d44a9cc5151615410db0b..a43ac8edfc5e3f6f61cd7758c36b94a329d80a03 100644 (file)
@@ -133,6 +133,16 @@ int fr_bio_free(fr_bio_t *bio)
        return talloc_free(bio);
 }
 
+static ssize_t fr_bio_shutdown_read(UNUSED fr_bio_t *bio, UNUSED void *packet_ctx, UNUSED void *buffer, UNUSED size_t size)
+{
+       return fr_bio_error(SHUTDOWN);
+}
+
+static ssize_t fr_bio_shutdown_write(UNUSED fr_bio_t *bio, UNUSED void *packet_ctx, UNUSED void const *buffer, UNUSED size_t size)
+{
+       return fr_bio_error(SHUTDOWN);
+}
+
 /** Shut down a set of BIOs
  *
  *  We shut down the BIOs from the top to the bottom.  This gives the TLS BIO an opportunity to
@@ -164,6 +174,9 @@ int fr_bio_shutdown(fr_bio_t *bio)
                 */
                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;
        }
 
        /*
index c1d95b6c1dd16a8310a98d6b7364d6675a6a3500..db36e9f09e6125e8b5a5fe263c788f32b55cb1ce 100644 (file)
@@ -54,6 +54,7 @@ typedef enum {
        FR_BIO_ERROR_VERIFY,                            //!< some packet verification error
        FR_BIO_ERROR_BUFFER_FULL,                       //!< the buffer is full
        FR_BIO_ERROR_BUFFER_TOO_SMALL,                  //!< the output buffer is too small for the data
+       FR_BIO_ERROR_SHUTDOWN,                          //!< the BIO has been shut down
 } fr_bio_error_type_t;
 
 typedef struct fr_bio_s fr_bio_t;