25#include <freeradius-devel/bio/bio_priv.h>
26#include <freeradius-devel/bio/null.h>
27#include <freeradius-devel/util/syserror.h>
95 for (
this = first;
this != NULL;
this =
fr_bio_next(
this)) {
98 if (my->priv_cb.shutdown) {
99 rcode = my->priv_cb.shutdown(&my->bio);
100 if (rcode < 0)
return rcode;
101 my->priv_cb.shutdown = NULL;
106 talloc_set_destructor(my, NULL);
123 my->shutdown_pending =
false;
126 if (rcode < 0)
return rcode;
133 if (my->cb.shutdown) {
134 rcode = my->cb.shutdown(
head);
135 if (rcode < 0)
return rcode;
136 my->cb.shutdown = NULL;
186 my->shutdown_pending =
true;
193 if (!stopped)
return 0;
232 return "IO operation would block";
241 return "Out of memory";
244 return "Packet fails verification";
247 return "Output buffer is full";
250 return "Output buffer is too small to cache the data";
253 return "The IO handler is not available. It has been shut down due to a previous error";
265 memset(&my->cb, 0,
sizeof(my->cb));
307 this->cb.eof(&this->bio);
325 if (!this->priv_cb.eof)
continue;
335 this->priv_cb.eof = NULL;
359 if (this->cb.write_blocked) {
360 rcode = this->cb.write_blocked(&this->bio);
361 if (rcode < 0)
return rcode;
362 is_blocked &= (rcode == 1);
372 if (!this->priv_cb.write_blocked)
continue;
379 rcode = this->priv_cb.write_blocked((
fr_bio_t *)
this);
380 if (rcode < 0)
return rcode;
381 is_blocked &= (rcode == 1);
static int const char char buffer[256]
fr_bio_write_t _CONST write
write to the underlying bio
static fr_bio_t * fr_bio_prev(fr_bio_t *bio)
fr_bio_read_t _CONST read
read from the underlying bio
static fr_bio_t * fr_bio_next(fr_bio_t *bio)
static fr_bio_t * fr_bio_head(fr_bio_t *bio)
static int packet_ctx
the tests pass only the address of packet_ctx
#define FR_BIO_DESTRUCTOR_COMMON
Define a common destructor pattern.
char const * fr_bio_strerror(ssize_t error)
int fr_bio_write_blocked(fr_bio_t *bio)
Internal BIO function to tell all BIOs that it's blocked.
ssize_t fr_bio_shutdown_read(UNUSED fr_bio_t *bio, UNUSED void *packet_ctx, UNUSED void *buffer, UNUSED size_t size)
void fr_bio_cb_set(fr_bio_t *bio, fr_bio_cb_funcs_t const *cb)
int fr_bio_shutdown_intermediate(fr_bio_t *bio)
Like fr_bio_shutdown(), but can be called by anyone in the chain.
int fr_bio_shutdown_discard(fr_bio_t *bio)
Shut down the chain now, discarding anything which is still buffered.
static int fr_bio_shutdown_final(fr_bio_t *bio)
Finish a shutdown: tear down the whole chain, and tell the application.
int fr_bio_destructor(fr_bio_t *bio)
Free this bio.
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_next_read(fr_bio_t *bio, void *packet_ctx, void *buffer, size_t size)
Internal bio function which just reads from the "next" bio.
fr_bio_t * fr_bio_eof(fr_bio_t *bio)
Internal BIO function to run EOF callbacks.
ssize_t fr_bio_next_write(fr_bio_t *bio, void *packet_ctx, void const *buffer, size_t size)
Internal bio function which just writes to the "next" bio.
int fr_bio_shutdown(fr_bio_t *bio)
Shut down a set of BIOs.
static int fr_bio_shutdown_chain(fr_bio_t *first)
Tear down every bio from "first" to the end of the chain.
ssize_t fr_bio_null_read(UNUSED fr_bio_t *bio, UNUSED void *packet_ctx, UNUSED void *buffer, UNUSED size_t size)
Always return 0 on read.
char const * fr_syserror(int num)
Guaranteed to be thread-safe version of strerror.
char const * fr_strerror(void)
Get the last library error.