*/
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.
*/
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);
}
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
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