BIO abstractions for in-memory pipes.
More...
#include <freeradius-devel/bio/bio_priv.h>
#include <freeradius-devel/bio/null.h>
#include <freeradius-devel/bio/mem.h>
#include <freeradius-devel/bio/pipe.h>
#include <pthread.h>
Go to the source code of this file.
BIO abstractions for in-memory pipes.
- Id
- a4cf06eec50227ddf42a428f14c9332cb4ed6b37
- Copyright
- 2024 Network RADIUS SAS (legal.nosp@m.@net.nosp@m.workr.nosp@m.adiu.nosp@m.s.com)
Definition in file pipe.c.
◆ fr_bio_pipe_t
The pipe bio.
Definition at line 35 of file pipe.c.
◆ fr_bio_pipe_alloc()
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, iqt'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 172 of file pipe.c.
◆ fr_bio_pipe_destructor()
◆ 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 143 of file pipe.c.
◆ fr_bio_pipe_read()
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.
◆ fr_bio_pipe_shutdown()
static void fr_bio_pipe_shutdown |
( |
fr_bio_t * |
bio | ) |
|
|
static |
Shutdown callback.
Definition at line 127 of file pipe.c.
◆ fr_bio_pipe_write()
Write to the pipe.
Once EOF is set, no further writes are possible.
Definition at line 96 of file pipe.c.