Control-plane signaling.
More...
#include <freeradius-devel/io/control.h>
#include <freeradius-devel/util/strerror.h>
#include <freeradius-devel/util/syserror.h>
#include <freeradius-devel/util/misc.h>
#include <freeradius-devel/util/rand.h>
#include <fcntl.h>
#include <sys/event.h>
#include <poll.h>
Go to the source code of this file.
|
| static int | _control_free (fr_control_t *c) |
| | Free a control structure.
|
| |
| int | fr_control_callback_add (fr_control_t **c, uint32_t id, void *ctx, fr_control_callback_t callback) |
| | Register a callback for an ID.
|
| |
| int | fr_control_callback_delete (fr_control_t *c, uint32_t id) |
| | Delete a callback for an ID.
|
| |
| fr_control_t * | fr_control_create (TALLOC_CTX *ctx, fr_event_list_t *el, fr_atomic_queue_t *aq, size_t num_callbacks) |
| | Create a control-plane signaling path.
|
| |
| int | fr_control_gc (UNUSED fr_control_t *c, fr_ring_buffer_t *rb) |
| | Clean up messages in a control-plane buffer.
|
| |
| static fr_control_message_t * | fr_control_message_alloc (fr_control_t *c, fr_ring_buffer_t *rb, uint32_t id, void *data, size_t data_size) |
| | Allocate a control message.
|
| |
| ssize_t | fr_control_message_pop (fr_atomic_queue_t *aq, uint32_t *p_id, void *data, size_t data_size) |
| | Pop control-plane message.
|
| |
| int | fr_control_message_push (fr_control_t *c, fr_ring_buffer_t *rb, uint32_t id, void *data, size_t data_size) |
| | Push a control-plane message.
|
| |
| int | fr_control_message_send (fr_control_t *c, fr_ring_buffer_t *rb, uint32_t id, void *data, size_t data_size) |
| | Send a control-plane message.
|
| |
| int | fr_control_open (fr_control_t *c) |
| | Open the control-plane signalling path.
|
| |
| int | fr_control_same_thread (fr_control_t *c) |
| |
| void | fr_control_wait (fr_control_t *c) |
| | Wait for a plane control to become readable.
|
| |
| static void | pipe_read (UNUSED fr_event_list_t *el, int fd, UNUSED int flags, void *uctx) |
| |
Control-plane signaling.
- Id
- 28e597328ede2cc95d2220a5d68e435681f7ec56
- Copyright
- 2016 Alan DeKok (aland.nosp@m.@fre.nosp@m.eradi.nosp@m.us.o.nosp@m.rg)
Definition in file control.c.
◆ fr_control_ctx_t
◆ fr_control_message_t
| struct fr_control_message_t |
The header for the control message.
Definition at line 59 of file control.c.
◆ fr_control_s
The control structure.
Definition at line 76 of file control.c.
| Data Fields |
|
fr_atomic_queue_t * |
aq |
destination AQ |
|
fr_event_list_t * |
el |
our event list |
|
uint32_t |
num_callbacks |
the size of the callback array |
|
bool |
opened |
has the control path been opened. |
|
int |
pipe[2] |
our pipes |
|
bool |
same_thread |
are the two ends in the same thread |
|
fr_control_ctx_t |
type[] |
callbacks. Must be at the end of the structure as these are created by allocating a larger memory size.
|
◆ MPRINT
◆ fr_control_message_status_t
Status of control messages.
◆ fr_control_message_status_t
Status of control messages.
| Enumerator |
|---|
| FR_CONTROL_MESSAGE_FREE | the message is free
|
| FR_CONTROL_MESSAGE_USED | the message is used (set only by originator)
|
| FR_CONTROL_MESSAGE_DONE | the message is done (set only by receiver)
|
Definition at line 49 of file control.c.
◆ _control_free()
Free a control structure.
This function really only calls the underlying "garbage collect".
- Parameters
-
| [in] | c | the control structure |
Definition at line 127 of file control.c.
◆ fr_control_callback_add()
Register a callback for an ID.
- Parameters
-
| [in] | c | the control structure |
| [in] | id | the ident of this message. |
| [in] | ctx | the context for the callback |
| [in] | callback | the callback function |
- Returns
-
Definition at line 443 of file control.c.
◆ fr_control_callback_delete()
Delete a callback for an ID.
- Parameters
-
| [in] | c | the control structure |
| [in] | id | the ident of this message. |
- Returns
-
Definition at line 502 of file control.c.
◆ fr_control_create()
Create a control-plane signaling path.
- Parameters
-
| [in] | ctx | the talloc context |
| [in] | el | the event list for the control socket |
| [in] | aq | the atomic queue where we will be pushing message data |
| [in] | num_callbacks | the initial number of callback entries to allocate. |
- Returns
- NULL on error
- fr_control_t on success
Definition at line 152 of file control.c.
◆ fr_control_gc()
Clean up messages in a control-plane buffer.
Find the oldest messages which are marked FR_CONTROL_MESSAGE_DONE, and mark them FR_CONTROL_MESSAGE_FREE.
- Parameters
-
| [in] | c | the fr_control_t |
| [in] | rb | the callers ring buffer for message allocation. |
- Returns
- <0 there are still messages used
- 0 the control list is empty.
Definition at line 216 of file control.c.
◆ fr_control_message_alloc()
Allocate a control message.
- Parameters
-
| [in] | c | the control structure |
| [in] | rb | the callers ring buffer for message allocation. |
| [in] | id | the ident of this message. |
| [in] | data | the data to write to the control plane |
| [in] | data_size | the size of the data to write to the control plane. |
- Returns
-
Definition at line 268 of file control.c.
◆ fr_control_message_pop()
Pop control-plane message.
This function is called ONLY from the receiving thread.
- Parameters
-
| [in] | aq | the recipients atomic queue for control-plane messages |
| [out] | p_id | the ident of this message. |
| [in,out] | data | where the data is stored |
| [in] | data_size | the size of the buffer where we store the data. |
- Returns
- <0 the size of the data we need to read the next message
- 0 this kevent is not for us.
- >0 the amount of data we've read
Definition at line 403 of file control.c.
◆ fr_control_message_push()
Push a control-plane message.
This function is called ONLY from the originating threads.
- Parameters
-
| [in] | c | the control structure |
| [in] | rb | the callers ring buffer for message allocation. |
| [in] | id | the ident of this message. |
| [in] | data | the data to write to the control plane |
| [in] | data_size | the size of the data to write to the control plane. |
- Returns
- -2 on ring buffer full
- <0 on error
- 0 on success
Definition at line 315 of file control.c.
◆ fr_control_message_send()
Send a control-plane message.
This function is called ONLY from the originating threads.
- Parameters
-
| [in] | c | the control structure |
| [in] | rb | the callers ring buffer for message allocation. |
| [in] | id | the ident of this message. |
| [in] | data | the data to write to the control plane |
| [in] | data_size | the size of the data to write to the control plane. |
- Returns
-
Definition at line 355 of file control.c.
◆ fr_control_open()
Open the control-plane signalling path.
- Parameters
-
| [in] | c | the control-plane to open |
- Returns
- 0 on success
- -1 on failure
Definition at line 176 of file control.c.
◆ fr_control_same_thread()
◆ fr_control_wait()
Wait for a plane control to become readable.
This is a blocking function so only to be used in rare cases such as waiting for another thread to complete a task before proceeding.
- Parameters
-
| [in] | c | the control structure. |
Definition at line 542 of file control.c.
◆ pipe_read()