The FreeRADIUS server $Id: 15bac2a4c627c01d1aa2047687b3418955ac7f00 $
Loading...
Searching...
No Matches
Data Structures | Functions
pipe.c File Reference

BIO abstractions for in-memory pipes. More...

#include <freeradius-devel/bio/bio_priv.h>
#include <freeradius-devel/bio/null.h>
#include <freeradius-devel/bio/buf.h>
#include <freeradius-devel/bio/pipe.h>
#include <pthread.h>
+ Include dependency graph for pipe.c:

Go to the source code of this file.

Data Structures

struct  fr_bio_pipe_t
 The pipe bio. More...
 

Functions

fr_bio_tfr_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 int fr_bio_pipe_destructor (fr_bio_pipe_t *my)
 
static int fr_bio_pipe_eof (fr_bio_t *bio)
 Set EOF.
 
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_shutdown (fr_bio_t *bio)
 Shutdown callback.
 
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 ssize_t fr_bio_pipe_write (fr_bio_t *bio, UNUSED void *packet_ctx, void const *buffer, size_t size)
 Write to the pipe.
 

Detailed Description

BIO abstractions for in-memory pipes.

Id
98512ef941fe5d69d84ebd6209d7ae929ddcdf8f

Definition in file pipe.c.


Data Structure Documentation

◆ fr_bio_pipe_t

struct fr_bio_pipe_t

The pipe bio.

Definition at line 35 of file pipe.c.

+ Collaboration diagram for fr_bio_pipe_t:
Data Fields
fr_bio_buf_t buf for reading and writing
bool eof are we at EOF?
FR_BIO_COMMON
pthread_mutex_t mutex

Function Documentation

◆ fr_bio_pipe_alloc()

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.

Due to talloc issues with multiple threads, if the caller wants a bi-directional pipe, this function will need to be called twice. That way a free in each context won't result in a race condition on two mutex locks.

For now, it's too difficult to emulate the pipe[2] behavior, where two identical "connected" things are returned, and either can be used for reading or for writing.

i.e. a pipe is really a mutex-protected memory buffer. One side should call write (and never read). The other side should call read (and never write).

The pipe should be freed only after both ends have set EOF.

Definition at line 181 of file pipe.c.

+ Here is the call graph for this function:

◆ fr_bio_pipe_destructor()

static int fr_bio_pipe_destructor ( fr_bio_pipe_t my)
static

Definition at line 46 of file pipe.c.

+ Here is the caller graph for this function:

◆ fr_bio_pipe_eof()

static int fr_bio_pipe_eof ( fr_bio_t bio)
static

Set EOF.

Either side can set EOF, in which case pending reads are still processed. Writes return EOF immediately. Readers return pending data, and then EOF.

Definition at line 144 of file pipe.c.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ fr_bio_pipe_read()

static ssize_t fr_bio_pipe_read ( fr_bio_t bio,
UNUSED void *  packet_ctx,
void *  buffer,
size_t  size 
)
static

Read from the pipe.

Once EOF is set, any pending data is read, and then EOF is returned.

Definition at line 59 of file pipe.c.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ fr_bio_pipe_shutdown()

static int fr_bio_pipe_shutdown ( fr_bio_t bio)
static

Shutdown callback.

Definition at line 121 of file pipe.c.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ fr_bio_pipe_shutdown_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

Definition at line 133 of file pipe.c.

+ Here is the caller graph for this function:

◆ fr_bio_pipe_write()

static ssize_t fr_bio_pipe_write ( fr_bio_t bio,
UNUSED void *  packet_ctx,
void const *  buffer,
size_t  size 
)
static

Write to the pipe.

Once EOF is set, no further writes are possible.

Definition at line 94 of file pipe.c.

+ Here is the call graph for this function:
+ Here is the caller graph for this function: