The FreeRADIUS server  $Id: 15bac2a4c627c01d1aa2047687b3418955ac7f00 $
Data Structures | Typedefs | Functions
io.h File Reference

Redis asynchronous I/O connection allocation. More...

#include <freeradius-devel/redis/base.h>
#include <freeradius-devel/util/event.h>
#include <freeradius-devel/server/connection.h>
#include <hiredis/async.h>
+ Include dependency graph for io.h:
+ This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Data Structures

struct  fr_redis_handle_t
 Store I/O state. More...
 
struct  fr_redis_io_conf_t
 
struct  fr_redis_sqn_ignore_t
 

Typedefs

typedef uint64_t fr_redis_sqn_t
 

Functions

fr_connection_tfr_redis_connection_alloc (TALLOC_CTX *ctx, fr_event_list_t *el, fr_connection_conf_t const *conn_conf, fr_redis_io_conf_t const *io_conf, char const *log_prefix)
 Allocate an async redis I/O connection. More...
 
redisAsyncContext * fr_redis_connection_get_async_ctx (fr_connection_t *conn)
 Return the redisAsyncContext associated with the connection. More...
 
static void fr_redis_connection_ignore_response (fr_redis_handle_t *h, fr_redis_sqn_t sqn)
 Ignore a response with a specific sequence number. More...
 
static bool fr_redis_connection_process_response (fr_redis_handle_t *h)
 Update the response sequence number and check if we should ignore the response. More...
 
static fr_redis_sqn_t fr_redis_connection_sent_request (fr_redis_handle_t *h)
 Tell the handle we sent a command, and get the SQN that command was assigned. More...
 

Detailed Description

Redis asynchronous I/O connection allocation.

Id
4ca4698a31886d7684a78504386801f903c58098
Author
Arran Cudbard-Bell (a.cud.nosp@m.bard.nosp@m.b@fre.nosp@m.erad.nosp@m.ius.o.nosp@m.rg)

Definition in file io.h.


Data Structure Documentation

◆ fr_redis_handle_t

struct fr_redis_handle_t

Store I/O state.

There are three layers of wrapping structures

fr_connection_t -> fr_redis_handle_t -> redisAsyncContext

Definition at line 66 of file io.h.

+ Collaboration diagram for fr_redis_handle_t:
Data Fields
redisAsyncContext * ac Async handle for hiredis.
fr_dlist_head_t ignore Contains SQNs for responses that should be ignored.
bool ignore_disconnect_cb Ensure that redisAsyncFree doesn't cause a callback loop.
bool read_set We're listening for reads.
fr_redis_sqn_t req_sqn Current redis request number.

Note: It would take 5.8 million years running at 100,000 requests/s to overflow, but my OCD requires that the max uses for trunk connections is set to UINT64_MAX if not specified by the user. It's one branch, and it makes me happy, deal with it.

fr_redis_sqn_t rsp_sqn Current redis response number.
fr_event_timer_t const * timer Connection timer.
bool write_set We're listening for writes.

◆ fr_redis_io_conf_t

struct fr_redis_io_conf_t

Definition at line 41 of file io.h.

+ Collaboration diagram for fr_redis_io_conf_t:
Data Fields
fr_time_delta_t connection_timeout
uint32_t database number on Redis server.
char * hostname
char const * log_prefix
char const * password to authenticate to Redis.
uint16_t port
fr_time_delta_t reconnection_delay

◆ fr_redis_sqn_ignore_t

struct fr_redis_sqn_ignore_t

Definition at line 54 of file io.h.

+ Collaboration diagram for fr_redis_sqn_ignore_t:
Data Fields
fr_dlist_t entry
fr_redis_sqn_t sqn

Typedef Documentation

◆ fr_redis_sqn_t

typedef uint64_t fr_redis_sqn_t

Definition at line 52 of file io.h.

Function Documentation

◆ fr_redis_connection_alloc()

fr_connection_t* fr_redis_connection_alloc ( TALLOC_CTX *  ctx,
fr_event_list_t el,
fr_connection_conf_t const *  conn_conf,
fr_redis_io_conf_t const *  io_conf,
char const *  log_prefix 
)

Allocate an async redis I/O connection.

Definition at line 421 of file io.c.

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

◆ fr_redis_connection_get_async_ctx()

redisAsyncContext* fr_redis_connection_get_async_ctx ( fr_connection_t conn)

Return the redisAsyncContext associated with the connection.

This is needed to issue commands to the redis server.

Parameters
[in]connTo retrieve async ctx from.
Returns
The async ctx.

Definition at line 454 of file io.c.

◆ fr_redis_connection_ignore_response()

static void fr_redis_connection_ignore_response ( fr_redis_handle_t h,
fr_redis_sqn_t  sqn 
)
inlinestatic

Ignore a response with a specific sequence number.

Parameters
[in]hto ignore the response on.
[in]sqnthe command to ignore.

Definition at line 106 of file io.h.

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

◆ fr_redis_connection_process_response()

static bool fr_redis_connection_process_response ( fr_redis_handle_t h)
inlinestatic

Update the response sequence number and check if we should ignore the response.

MUST be called for every reply received using the handle. Relies on the fact that responses from REDIS are FIFO with requests.

Parameters
[in]hto check for ignored responses.

Definition at line 124 of file io.h.

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

◆ fr_redis_connection_sent_request()

static fr_redis_sqn_t fr_redis_connection_sent_request ( fr_redis_handle_t h)
inlinestatic

Tell the handle we sent a command, and get the SQN that command was assigned.

MUST be called for every command sent using the handle. Relies on the fact that responses from REDIS are FIFO with requests.

Parameters
[in]hthe request was sent on.
Returns
the handle specific SQN.

Definition at line 96 of file io.h.

+ Here is the caller graph for this function: