24#include <freeradius-devel/bio/bio_priv.h>
25#include <freeradius-devel/bio/null.h>
26#include <freeradius-devel/bio/buf.h>
28#include <freeradius-devel/bio/pipe.h>
50 pthread_mutex_destroy(&
my->mutex);
64 pthread_mutex_lock(&
my->mutex);
71 pthread_mutex_unlock(&
my->mutex);
79 (void)
my->cb.write_resume(&
my->bio);
83 (void)
my->cb.read_blocked(&
my->bio);
99 pthread_mutex_lock(&
my->mutex);
102 if (room < size) size = room;
107 pthread_mutex_unlock(&
my->mutex);
110 (void)
my->cb.read_resume(&
my->bio);
112 (void)
my->cb.write_blocked(&
my->bio);
125 pthread_mutex_lock(&
my->mutex);
128 pthread_mutex_unlock(&
my->mutex);
153 pthread_mutex_lock(&
my->mutex);
162 pthread_mutex_unlock(&
my->mutex);
188 if (!cb->
eof)
return NULL;
190 if (buffer_size < 1024) buffer_size = 1024;
191 if (buffer_size > (1 << 20)) buffer_size = (1 << 20);
194 if (!
my)
return NULL;
206 pthread_mutex_init(&
my->mutex, NULL);
static int const char char buffer[256]
fr_bio_callback_t eof
called when the BIO is at EOF
fr_bio_io_t read_resume
"unblocked" is too similar to "blocked"
fr_bio_io_t write_blocked
returns 0 for "couldn't block", 1 for "did block".
#define FR_BIO_DESTRUCTOR_COMMON
Define a common destructor pattern.
size_t fr_bio_buf_read(fr_bio_buf_t *bio_buf, void *buffer, size_t size)
ssize_t fr_bio_buf_write(fr_bio_buf_t *bio_buf, const void *buffer, size_t size)
static void fr_bio_buf_init(fr_bio_buf_t *bio_buf, uint8_t *buffer, size_t size)
static size_t fr_bio_buf_write_room(fr_bio_buf_t const *bio_buf)
static size_t fr_bio_buf_used(fr_bio_buf_t const *bio_buf)
void fr_bio_shutdown & my
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.
ssize_t fr_bio_fail_read(UNUSED fr_bio_t *bio, UNUSED void *packet_ctx, UNUSED void *buffer, UNUSED size_t size)
Always return error on read.
ssize_t fr_bio_fail_write(UNUSED fr_bio_t *bio, UNUSED void *packet_ctx, UNUSED void const *buffer, UNUSED size_t size)
Always return an error on write.
static ssize_t fr_bio_pipe_shutdown_write(UNUSED fr_bio_t *bio, UNUSED void *packet_ctx, UNUSED void const *buffer, UNUSED size_t size)
static int fr_bio_pipe_eof(fr_bio_t *bio)
Set EOF.
static ssize_t fr_bio_pipe_write(fr_bio_t *bio, UNUSED void *packet_ctx, void const *buffer, size_t size)
Write to the pipe.
static int fr_bio_pipe_shutdown(fr_bio_t *bio)
Shutdown callback.
fr_bio_buf_t buf
for reading and writing
fr_bio_t * fr_bio_pipe_alloc(TALLOC_CTX *ctx, fr_bio_cb_funcs_t *cb, size_t buffer_size)
Allocate a thread-safe pipe which can be used for both reads and writes.
static ssize_t fr_bio_pipe_read(fr_bio_t *bio, UNUSED void *packet_ctx, void *buffer, size_t size)
Read from the pipe.
static int fr_bio_pipe_destructor(fr_bio_pipe_t *my)
#define fr_strerror_const(_msg)