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);
77 my->priv_cb.
eof = NULL;
80 }
else if (size > 0) {
81 (void) my->cb.write_resume(&my->bio);
84 (void) my->cb.read_blocked(&my->bio);
100 pthread_mutex_lock(&my->
mutex);
103 if (room < size) size = room;
108 pthread_mutex_unlock(&my->
mutex);
111 (void) my->cb.read_resume(&my->bio);
113 (void) my->cb.write_blocked(&my->bio);
128 pthread_mutex_lock(&my->
mutex);
130 pthread_mutex_unlock(&my->
mutex);
159 pthread_mutex_lock(&my->
mutex);
168 pthread_mutex_unlock(&my->
mutex);
194 if (!cb->
eof)
return NULL;
196 if (buffer_size < 1024) buffer_size = 1024;
197 if (buffer_size > (1 << 20)) buffer_size = (1 << 20);
200 if (!my)
return NULL;
212 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".
static int packet_ctx
the tests pass only the address of packet_ctx
#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)
fr_bio_t * fr_bio_eof(fr_bio_t *bio)
Internal BIO function to run EOF callbacks.
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.
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)