]> git.ipfire.org Git - thirdparty/freeradius-server.git/commitdiff
just pass errors through on read / write
authorAlan T. DeKok <aland@freeradius.org>
Thu, 7 Aug 2025 12:34:32 +0000 (08:34 -0400)
committerAlan T. DeKok <aland@freeradius.org>
Thu, 7 Aug 2025 14:15:52 +0000 (10:15 -0400)
the underlying BIO should call fr_bio_shutdown() if there is a
fatal error.

src/lib/bio/base.c
src/lib/bio/base.h
src/lib/bio/fd.c

index 9b07726097bd8caedb7bf3c997a3e67fc3f0a024..0e00171cec9da79c86720dbd576411f3595f4355 100644 (file)
@@ -48,20 +48,12 @@ int fr_bio_destructor(fr_bio_t *bio)
  */
 ssize_t fr_bio_next_read(fr_bio_t *bio, void *packet_ctx, void *buffer, size_t size)
 {
-       ssize_t rcode;
        fr_bio_t *next;
 
        next = fr_bio_next(bio);
        fr_assert(next != NULL);
 
-       rcode = next->read(next, packet_ctx, buffer, size);
-       if (rcode >= 0) return rcode;
-
-       if (rcode == fr_bio_error(IO_WOULD_BLOCK)) return rcode;
-
-       bio->read = fr_bio_fail_read;
-       bio->write = fr_bio_fail_write;
-       return rcode;
+       return next->read(next, packet_ctx, buffer, size);
 }
 
 /** Internal bio function which just writes to the "next" bio.
@@ -71,28 +63,20 @@ ssize_t fr_bio_next_read(fr_bio_t *bio, void *packet_ctx, void *buffer, size_t s
  */
 ssize_t fr_bio_next_write(fr_bio_t *bio, void *packet_ctx, void const *buffer, size_t size)
 {
-       ssize_t rcode;
        fr_bio_t *next;
 
        next = fr_bio_next(bio);
        fr_assert(next != NULL);
 
-       rcode = next->write(next, packet_ctx, buffer, size);
-       if (rcode >= 0) return rcode;
-
-       if (rcode == fr_bio_error(IO_WOULD_BLOCK)) return rcode;
-
-       bio->read = fr_bio_fail_read;
-       bio->write = fr_bio_fail_write;
-       return rcode;
+       return next->write(next, packet_ctx, buffer, size);
 }
 
-static ssize_t fr_bio_shutdown_read(UNUSED fr_bio_t *bio, UNUSED void *packet_ctx, UNUSED void *buffer, UNUSED size_t size)
+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)
+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);
 }
index 4d83f920eafb3f2e5aaf97e0ce8422d7c1f282ee..cf2b65b4f6723aa2cf8e4b8820be7583b2982779 100644 (file)
@@ -194,4 +194,7 @@ char const *fr_bio_strerror(ssize_t error);
 
 void   fr_bio_cb_set(fr_bio_t *bio, fr_bio_cb_funcs_t const *cb) CC_HINT(nonnull(1));
 
+ssize_t fr_bio_shutdown_read(fr_bio_t *bio, void *packet_ctx, void *buffer, size_t size);
+ssize_t fr_bio_shutdown_write(fr_bio_t *bio, void *packet_ctx, void const *buffer, size_t size);
+
 #undef _CONST
index 8b12dfdf76e58c5abf3297079a4dc915da362db9..44262a905f9aed5a513d90102eb0705a286e32eb 100644 (file)
@@ -1008,8 +1008,8 @@ int fr_bio_fd_close(fr_bio_t *bio)
 
        if (my->info.state == FR_BIO_FD_STATE_CLOSED) return 0;
 
-       my->bio.read = fr_bio_fail_read;
-       my->bio.write = fr_bio_fail_write;
+       my->bio.read = fr_bio_shutdown_read;
+       my->bio.write = fr_bio_shutdown_write;
 
        /*
         *      Shut down the connected socket.  The only errors possible here are things we can't do anything