}
/*
- * We were flushing the buffer, return however much data we managed to write.
+ * We were flushing the BIO, return however much data we managed to write.
*
- * Note that flushes can never block.
+ * Note that flushes should never block.
*/
if (!buffer) {
fr_assert(rcode != fr_bio_error(IO_WOULD_BLOCK));
return rcode;
}
+ if (my->cb.write_blocked) {
+ int error;
+
+ error = my->cb.write_blocked(bio);
+ if (error < 0) return error;
+
+ fr_assert(error != 0); /* what to do? */
+ }
+
/*
* We had WOULD BLOCK, or wrote partial bytes. Save the data to the memory buffer, and ensure
* that future writes are ordered. i.e. they write to the memory buffer before writing to the
return 0;
}
+/*
+ * There's no fr_bio_mem_write_blocked()
+ */
+
/** See if we can resume writes to the memory bio.
*
* Note that there is no equivalent fr_bio_mem_write_blocked(), as that function wouldn't do anything.
if (bio->write != fr_bio_mem_write_buffer) return 1;
+ /*
+ * Flush the buffer, and then reset the write routine if we were successful.
+ */
rcode = fr_bio_mem_write_flush(my, SIZE_MAX);
if (rcode <= 0) return rcode;
if (fr_bio_buf_used(&my->write_buffer) > 0) return 0;
- return 1;
+ if (!my->cb.write_resume) return 1;
+
+ return my->cb.write_resume(bio);
}