]> git.ipfire.org Git - thirdparty/freeradius-server.git/commitdiff
rework the write_blocked() handlers
authorAlan T. DeKok <aland@freeradius.org>
Tue, 19 Nov 2024 19:30:26 +0000 (14:30 -0500)
committerAlan T. DeKok <aland@freeradius.org>
Tue, 19 Nov 2024 20:20:30 +0000 (15:20 -0500)
to match the EOF handlers, so I'm more convinced taht they're
correct.

src/lib/bio/fd.c
src/lib/bio/fd_write.h
src/lib/bio/mem.c
src/lib/bio/retry.c

index d0b41811de504c0e5a50f0682da78041e288a650..dadf3040993c09ff04d1e50e6894a3a239af41f5 100644 (file)
@@ -728,12 +728,10 @@ retry:
                  */
         case EINPROGRESS:
                if (!my->info.write_blocked) {
-                       if (my->cb.write_blocked) {
-                               rcode = my->cb.write_blocked((fr_bio_t *) my);
-                               if (rcode < 0) return rcode;
-                       }
-
                        my->info.write_blocked = true;
+
+                       rcode = fr_bio_write_blocked((fr_bio_t *) my);
+                       if (rcode < 0) return rcode;
                }
 
                return fr_bio_error(IO_WOULD_BLOCK);
index b4a1b16d18bb7da7ccc1eb5a9292b6babb5448d7..56e3b2499eecc5913f029f0da0b5056fa88317eb 100644 (file)
@@ -24,10 +24,8 @@ if (rcode > 0) {
                 */
                my->info.write_blocked = true;
 
-               if (my->cb.write_blocked) {
-                       error = fr_bio_write_blocked((fr_bio_t *) my);
-                       if (error < 0) return error;
-               }
+               error = fr_bio_write_blocked((fr_bio_t *) my);
+               if (error < 0) return error;
 
                return rcode;   
        }
index a93341c5a1f5405e35f8cd399361d3396d6aa164..0a89735a050cda7a6fa9e4979d9a54440f618c2b 100644 (file)
@@ -369,6 +369,7 @@ fail:
  */
 static ssize_t fr_bio_mem_write_next(fr_bio_t *bio, void *packet_ctx, void const *buffer, size_t size)
 {
+       int error;
        ssize_t rcode;
        size_t room, leftover;
        fr_bio_mem_t *my = talloc_get_type_abort(bio, fr_bio_mem_t);
@@ -410,14 +411,13 @@ static ssize_t fr_bio_mem_write_next(fr_bio_t *bio, void *packet_ctx, void const
                return rcode;
        }
 
-       if (my->cb.write_blocked) {
-               int error;
-
-               error = my->cb.write_blocked(bio);
-               if (error < 0) return error;
+       /*
+        *      Tell previous BIOs in the chain that they are blocked.
+        */
+       error = fr_bio_write_blocked(bio);
+       if (error < 0) return error;
 
-               fr_assert(error != 0); /* what to do? */
-       }
+       fr_assert(error != 0); /* what to do? */
 
        /*
         *      We had WOULD BLOCK, or wrote partial bytes.  Save the data to the memory buffer, and ensure
index 4d6439b8ceb609982052f61665bd41452ebb8f5e..36d31b3f36eb7b190156b8d8847fcaad2df1a96d 100644 (file)
@@ -764,7 +764,10 @@ static ssize_t fr_bio_retry_write(fr_bio_t *bio, void *packet_ctx, void const *b
                        my->info.write_blocked = true;
                        my->all_used = true;
 
-                       rcode = my->cb.write_blocked(bio);
+                       /*
+                        *      Previous BIOs are blocked, but we still try to write retries.
+                        */
+                       rcode = fr_bio_write_blocked(bio);
                        if (rcode < 0) return rcode;
 
                        return fr_bio_error(IO_WOULD_BLOCK);