The FreeRADIUS server
$Id: 15bac2a4c627c01d1aa2047687b3418955ac7f00 $
|
Functions for pipelining commands. More...
#include <freeradius-devel/server/connection.h>
#include <freeradius-devel/server/trunk.h>
#include "pipeline.h"
#include "io.h"
Go to the source code of this file.
Data Structures | |
struct | fr_redis_cluster_thread_s |
Thread local state for a cluster. More... | |
struct | fr_redis_command_s |
Represents a single command. More... | |
struct | fr_redis_command_set_s |
Represents a collection of pipelined commands. More... | |
struct | fr_redis_trunk_s |
Macros | |
#define | COMMAND_PRE_ALLOC_COUNT 8 |
#define | COMMAND_PRE_ALLOC_LEN 64 |
Enumerations | |
enum | fr_redis_command_type_t { FR_REDIS_COMMAND_NORMAL = 0 , FR_REDIS_COMMAND_TRANSACTION_START , FR_REDIS_COMMAND_TRANSACTION_END } |
Functions | |
static int | _command_set_free_list_free_on_exit (void *arg) |
Free any free requests when the thread is joined. More... | |
static int | _redis_command_free (fr_redis_command_t *cmd) |
Free any result associated with the command. More... | |
static int | _redis_command_set_free (fr_redis_command_set_t *cmds) |
Free a command set. More... | |
static void | _redis_pipeline_command_set_cancel (connection_t *conn, UNUSED trunk_request_t *treq, void *preq, trunk_cancel_reason_t reason, UNUSED void *uctx) |
Deal with cancellation of sent requests. More... | |
static void | _redis_pipeline_command_set_complete (UNUSED request_t *request, void *preq, UNUSED void *rctx, UNUSED void *uctx) |
Signal the API client that we got a complete set of responses to a command set. More... | |
static void | _redis_pipeline_command_set_fail (UNUSED request_t *request, void *preq, UNUSED void *rctx, UNUSED void *uctx) |
Signal the API client that we failed enqueuing the commands. More... | |
static void | _redis_pipeline_command_set_free (UNUSED request_t *request, void *preq, UNUSED void *uctx) |
Free the command set. More... | |
static connection_t * | _redis_pipeline_connection_alloc (trunk_connection_t *tconn, fr_event_list_t *el, connection_conf_t const *conf, char const *log_prefix, void *uctx) |
static void | _redis_pipeline_demux (struct redisAsyncContext *ac, void *vreply, void *privdata) |
Callback for for receiving Redis replies. More... | |
static void | _redis_pipeline_mux (trunk_connection_t *tconn, connection_t *conn, UNUSED void *uctx) |
Enqueue one or more command sets onto a redis handle. More... | |
fr_redis_cluster_thread_t * | fr_redis_cluster_thread_alloc (TALLOC_CTX *ctx, fr_event_list_t *el, trunk_conf_t const *tconf) |
Allocate per-thread, per-cluster instance. More... | |
redisReply * | fr_redis_command_get_result (fr_redis_command_t *cmd) |
fr_redis_pipeline_status_t | fr_redis_command_preformatted_add (fr_redis_command_set_t *cmds, char const *cmd_str, size_t cmd_len) |
Add a preformatted/expanded command to the command set. More... | |
fr_redis_command_set_t * | fr_redis_command_set_alloc (TALLOC_CTX *ctx, request_t *request, fr_redis_command_set_complete_t complete, fr_redis_command_set_fail_t fail, void *rctx) |
Allocate a new command set. More... | |
fr_redis_trunk_t * | fr_redis_trunk_alloc (fr_redis_cluster_thread_t *cluster_thread, fr_redis_io_conf_t const *io_conf) |
Allocate a new trunk. More... | |
fr_redis_pipeline_status_t | redis_command_set_enqueue (fr_redis_trunk_t *rtrunk, fr_redis_command_set_t *cmds) |
Enqueue a command set on a specific trunk. More... | |
Variables | |
static _Thread_local fr_dlist_head_t * | command_set_free_list |
The thread local free list. More... | |
Functions for pipelining commands.
Definition in file pipeline.c.
struct fr_redis_cluster_thread_s |
Thread local state for a cluster.
MOVE ME TO NEW ASYNC CLUSTER CODE
Definition at line 39 of file pipeline.c.
Data Fields | ||
---|---|---|
bool | delay_start | Prevent connections from spawning immediately. |
fr_event_list_t * | el | |
char * | log_prefix | Common log prefix to use for all cluster related messages. |
trunk_conf_t const * | tconf | Configuration for all trunks in the cluster. |
struct fr_redis_command_s |
Represents a single command.
Definition at line 67 of file pipeline.c.
Data Fields | ||
---|---|---|
fr_redis_command_set_t * | cmds | Command set this entry belongs to. |
fr_dlist_t | entry | Entry in the command buffer. |
size_t | len | Length of the command string. |
redisReply * | result | The result from the REDIS server. |
uint64_t | sqn |
The sequence number of the command. This is only valid for a specific handle, and is unique within the handle. |
char const * | str | The command string. |
fr_redis_command_type_t | type | Redis command type. |
struct fr_redis_command_set_s |
Represents a collection of pipelined commands.
Commands MUST map to the same cluster node if using clustering.
Definition at line 87 of file pipeline.c.
Data Fields | ||
---|---|---|
fr_redis_command_set_complete_t | complete |
Notify the creator of the command set that the command set has executed to to completion. We have results for all commands. |
fr_dlist_head_t | completed | Commands complete with replies. |
fr_dlist_t | entry | |
fr_redis_command_set_fail_t | fail |
Notify the creator of the command set that the command set failed to execute to completion. Partial results will be available. |
fr_dlist_head_t | pending | Commands yet to be sent. |
void * | rctx | Resume context to write results to. |
uint8_t | redirected | How many times this command set was redirected. |
request_t * | request | Request this commands set is associated with (if any). |
fr_dlist_head_t | sent | Commands sent. |
trunk_request_t * | treq | Trunk request this command set is associated with. |
uint16_t | txn_end | The number of times a transaction block ended in this command set. |
uint16_t | txn_start | Number of times a transaction block was started in this command set. |
bool | txn_watch | Transaction was started with a watch statement. |
struct fr_redis_trunk_s |
Definition at line 144 of file pipeline.c.
Data Fields | ||
---|---|---|
fr_redis_cluster_thread_t * | cluster | Cluster this trunk belongs to. |
fr_redis_io_conf_t const * | io_conf |
Redis I/O configuration. Specifies how to connect to the host this trunk is used to communicate with. |
trunk_t * | trunk |
Trunk containing all the connections to a specific. host. |
#define COMMAND_PRE_ALLOC_COUNT 8 |
#define COMMAND_PRE_ALLOC_LEN 64 |
Definition at line 53 of file pipeline.c.
|
static |
Free any free requests when the thread is joined.
Definition at line 155 of file pipeline.c.
|
static |
Free any result associated with the command.
[in] | cmd | to free. Frees any redis results associated with the command. |
Definition at line 263 of file pipeline.c.
|
static |
Free a command set.
Definition at line 170 of file pipeline.c.
|
static |
Deal with cancellation of sent requests.
We can't actually signal redis to not process the request, so depending on why the commands were cancelled, we either tell the handle to ignore them, or move them back into the pending list.
Definition at line 522 of file pipeline.c.
|
static |
Signal the API client that we got a complete set of responses to a command set.
Definition at line 577 of file pipeline.c.
|
static |
Signal the API client that we failed enqueuing the commands.
Definition at line 588 of file pipeline.c.
|
static |
Free the command set.
Definition at line 599 of file pipeline.c.
|
static |
Definition at line 464 of file pipeline.c.
|
static |
Callback for for receiving Redis replies.
This is called by hiredis for each response is receives. privData is set to the fr_command_set
[in] | ac | The async context the command was enqueued on. |
[in] | vreply | redisReply containing the result of the command. |
[in] | privdata | fr_redis_command_t that was sent to the Redis server. The fr_redis_command_t contains a pointer to the fr_redis_command_set_t which holds the treq which we use to signal that we have responses for all commands. |
Definition at line 427 of file pipeline.c.
|
static |
Enqueue one or more command sets onto a redis handle.
Because the trunk is in always writable mode, _redis_pipeline_mux will be called any time trunk_request_enqueue is called, so there'll only ever be one command to dequeue.
[in] | tconn | Trunk connection holding the commands to enqueue. |
[in] | conn | Connection handle containing the fr_redis_handle_t. |
[in] | uctx | fr_redis_cluster_t. Unused. |
Definition at line 483 of file pipeline.c.
fr_redis_cluster_thread_t* fr_redis_cluster_thread_alloc | ( | TALLOC_CTX * | ctx, |
fr_event_list_t * | el, | ||
trunk_conf_t const * | tconf | ||
) |
Allocate per-thread, per-cluster instance.
This structure represents all the connections for a given thread for a given cluster. The structures holds the trunk connections to talk to each cluster member.
Definition at line 647 of file pipeline.c.
redisReply* fr_redis_command_get_result | ( | fr_redis_command_t * | cmd | ) |
fr_redis_pipeline_status_t fr_redis_command_preformatted_add | ( | fr_redis_command_set_t * | cmds, |
char const * | cmd_str, | ||
size_t | cmd_len | ||
) |
Add a preformatted/expanded command to the command set.
The command must either be entirely static, or parented by the command set.
[in] | cmds | Command set to add command to. |
[in] | cmd_str | A fully expanded/formatted command to send to redis. Must be static, or have the same lifetime as the command set (allocated with the command set as the parent). |
[in] | cmd_len | Length of the command. |
Definition at line 292 of file pipeline.c.
fr_redis_command_set_t* fr_redis_command_set_alloc | ( | TALLOC_CTX * | ctx, |
request_t * | request, | ||
fr_redis_command_set_complete_t | complete, | ||
fr_redis_command_set_fail_t | fail, | ||
void * | rctx | ||
) |
Allocate a new command set.
This is a set of commands that the calling module wants to execute on the redis server in sequence.
Control will be returned to the caller via the registered complete and fail functions.
[in] | ctx | to bind the command set's lifetime to. |
[in] | request | to pass to places that need it. |
[in] | complete | Function to call when all commands have been processed. |
[in] | fail | Function to call if the command set was not executed or was partially executed. |
[in] | rctx | Resume context to pass to complete and fail functions. |
Definition at line 206 of file pipeline.c.
fr_redis_trunk_t* fr_redis_trunk_alloc | ( | fr_redis_cluster_thread_t * | cluster_thread, |
fr_redis_io_conf_t const * | io_conf | ||
) |
Allocate a new trunk.
[in] | cluster_thread | to allocate the trunk for. |
[in] | io_conf | Describing the connection to a single REDIS host. |
Definition at line 615 of file pipeline.c.
fr_redis_pipeline_status_t redis_command_set_enqueue | ( | fr_redis_trunk_t * | rtrunk, |
fr_redis_command_set_t * | cmds | ||
) |
Enqueue a command set on a specific trunk.
The command set may be passed around several trunks before it is complete. This is to allow it to follow MOVED and ASK responses.
[in] | rtrunk | to enqueue command set on. |
[in] | cmds | Command set to enqueue. |
Definition at line 392 of file pipeline.c.
|
static |
The thread local free list.
Any entries remaining in the list will be freed when the thread is joined
Definition at line 51 of file pipeline.c.