24 #include <freeradius-devel/bio/bio_priv.h>
25 #include <freeradius-devel/bio/null.h>
26 #include <freeradius-devel/bio/mem.h>
28 #include <freeradius-devel/bio/pipe.h>
50 pthread_mutex_destroy(&
my->mutex);
66 pthread_mutex_lock(&
my->mutex);
67 rcode =
my->next->read(
my->next, packet_ctx,
buffer, size);
68 if ((rcode == 0) &&
my->eof) {
69 pthread_mutex_unlock(&
my->mutex);
74 my->priv_cb.eof = NULL;
78 }
else if (rcode > 0) {
84 my->signal.writeable(&
my->bio);
86 pthread_mutex_unlock(&
my->mutex);
103 pthread_mutex_lock(&
my->mutex);
105 rcode =
my->next->write(
my->next, packet_ctx,
buffer, size);
113 my->signal.readable(&
my->bio);
119 pthread_mutex_unlock(&
my->mutex);
133 pthread_mutex_lock(&
my->mutex);
135 pthread_mutex_unlock(&
my->mutex);
147 pthread_mutex_lock(&
my->mutex);
149 pthread_mutex_unlock(&
my->mutex);
178 if (buffer_size < 1024) buffer_size = 1024;
179 if (buffer_size > (1 << 20)) buffer_size = (1 << 20);
182 if (!
my)
return NULL;
192 pthread_mutex_init(&
my->mutex, NULL);
static int const char char buffer[256]
void fr_bio_eof(fr_bio_t *bio)
Internal BIO function to run EOF callbacks.
int fr_bio_shutdown(fr_bio_t *bio)
Shut down a set of BIOs.
fr_bio_t * fr_bio_mem_sink_alloc(TALLOC_CTX *ctx, size_t read_size)
Allocate a memory buffer which sinks data from a bio system into the callers application.
static int fr_bio_pipe_eof(fr_bio_t *bio)
Set EOF.
static ssize_t fr_bio_pipe_read(fr_bio_t *bio, void *packet_ctx, void *buffer, size_t size)
Read from the pipe.
fr_bio_t * fr_bio_pipe_alloc(TALLOC_CTX *ctx, fr_bio_pipe_cb_funcs_t *cb, size_t buffer_size)
Allocate a thread-safe pipe which can be used for both reads and writes.
static void fr_bio_pipe_shutdown(fr_bio_t *bio)
Shutdown callback.
fr_bio_pipe_cb_funcs_t signal
inform us that the pipe is readable
static ssize_t fr_bio_pipe_write(fr_bio_t *bio, void *packet_ctx, void const *buffer, size_t size)
Write to the pipe.
static int fr_bio_pipe_destructor(fr_bio_pipe_t *my)
fr_bio_callback_t writeable
fr_bio_callback_t readable