The FreeRADIUS server  $Id: 15bac2a4c627c01d1aa2047687b3418955ac7f00 $
Data Structures | Macros | Typedefs | Functions
retry.c File Reference

Binary IO abstractions for retrying packets. More...

#include <freeradius-devel/bio/bio_priv.h>
#include <freeradius-devel/bio/null.h>
#include <freeradius-devel/bio/buf.h>
#include <freeradius-devel/util/rb.h>
#include <freeradius-devel/util/dlist.h>
#include <freeradius-devel/bio/retry.h>
+ Include dependency graph for retry.c:

Go to the source code of this file.

Data Structures

struct  fr_bio_retry_entry_s
 
union  fr_bio_retry_entry_s.__unnamed9__
 
struct  fr_bio_retry_s
 

Macros

#define _BIO_RETRY_PRIVATE
 

Typedefs

typedef struct fr_bio_retry_list_s fr_bio_retry_list_t
 
typedef struct fr_bio_retry_s fr_bio_retry_t
 

Functions

static int8_t _entry_cmp (void const *one, void const *two)
 
fr_bio_tfr_bio_retry_alloc (TALLOC_CTX *ctx, size_t max_saved, fr_bio_retry_sent_t sent, fr_bio_retry_response_t response, fr_bio_retry_rewrite_t rewrite, fr_bio_retry_release_t release, fr_bio_retry_config_t const *cfg, fr_bio_t *next)
 Allocate a fr_bio_retry_t. More...
 
static ssize_t fr_bio_retry_blocked (fr_bio_retry_t *my, fr_bio_retry_entry_t *item, ssize_t rcode)
 The write is blocked. More...
 
static int fr_bio_retry_destructor (fr_bio_retry_t *my)
 Cancel all outstanding packets. More...
 
int fr_bio_retry_entry_cancel (fr_bio_t *bio, fr_bio_retry_entry_t *item)
 Cancel one item. More...
 
const fr_retry_tfr_bio_retry_entry_info (UNUSED fr_bio_t *bio, fr_bio_retry_entry_t *item)
 Allow the callbacks / application to know when things are being retried. More...
 
int fr_bio_retry_entry_start (UNUSED fr_bio_t *bio, fr_bio_retry_entry_t *item, fr_retry_config_t const *cfg)
 Set a per-packet retry config. More...
 
static ssize_t fr_bio_retry_read (fr_bio_t *bio, void *packet_ctx, void *buffer, size_t size)
 
static void fr_bio_retry_release (fr_bio_retry_t *my, fr_bio_retry_entry_t *item, fr_bio_retry_release_reason_t reason)
 Release an entry back to the free list. More...
 
static int fr_bio_retry_reset_timer (fr_bio_retry_t *my)
 Reset the timer after changing the rb tree. More...
 
ssize_t fr_bio_retry_rewrite (fr_bio_t *bio, fr_bio_retry_entry_t *item, const void *buffer, size_t size)
 Resend a packet. More...
 
static void fr_bio_retry_timer (UNUSED fr_event_list_t *el, fr_time_t now, void *uctx)
 Run a timer event. More...
 
static ssize_t fr_bio_retry_write (fr_bio_t *bio, void *packet_ctx, void const *buffer, size_t size)
 Write a request, and see if we have a reply. More...
 
static int fr_bio_retry_write_delayed (fr_bio_retry_t *my, fr_time_t now)
 
static ssize_t fr_bio_retry_write_fatal (fr_bio_t *bio, UNUSED void *packet_ctx, UNUSED void const *buffer, UNUSED size_t size)
 A previous timer write had a fatal error, so we forbid further writes. More...
 
static int fr_bio_retry_write_item (fr_bio_retry_t *my, fr_bio_retry_entry_t *item, fr_time_t now)
 Write one item. More...
 
static ssize_t fr_bio_retry_write_partial (fr_bio_t *bio, void *packet_ctx, const void *buffer, size_t size)
 There's a partial packet written. More...
 

Detailed Description

Binary IO abstractions for retrying packets.

Id
ecb49797dda4c8796c67e863159892b833e615ca

Definition in file retry.c.


Data Structure Documentation

◆ fr_bio_retry_entry_s

struct fr_bio_retry_entry_s

Definition at line 42 of file retry.c.

+ Collaboration diagram for fr_bio_retry_entry_s:
Data Fields
union fr_bio_retry_entry_s __unnamed__
uint8_t const * buffer
bool cancelled was this item cancelled?
fr_bio_retry_t * my so we can get to it from the event timer callback
void * packet_ctx packet_ctx from the write() call
fr_retry_t retry retry timers and counters
fr_bio_retry_rewrite_t rewrite per-packet rewrite callback
void * rewrite_ctx context specifically for rewriting this packet
size_t size
void * uctx user-writable context

◆ fr_bio_retry_entry_s.__unnamed9__

union fr_bio_retry_entry_s.__unnamed9__

Definition at line 47 of file retry.c.

Data Fields
fr_rb_node_t node for the timers

◆ fr_bio_retry_s

struct fr_bio_retry_s

Definition at line 63 of file retry.c.

+ Collaboration diagram for fr_bio_retry_s:
Data Fields
fr_bio_buf_t buffer
fr_event_list_t * el
ssize_t error
fr_event_timer_t const * ev
fr_bio_retry_entry_t * first for timers
FR_BIO_COMMON
fr_bio_retry_entry_t * partial for partial writes
fr_rb_tree_t rb
fr_bio_retry_release_t release
fr_bio_retry_response_t response
fr_retry_config_t retry_config
fr_bio_retry_rewrite_t rewrite
fr_bio_retry_sent_t sent

Macro Definition Documentation

◆ _BIO_RETRY_PRIVATE

#define _BIO_RETRY_PRIVATE

Definition at line 31 of file retry.c.

Typedef Documentation

◆ fr_bio_retry_list_t

typedef struct fr_bio_retry_list_s fr_bio_retry_list_t

Definition at line 1 of file retry.c.

◆ fr_bio_retry_t

Definition at line 1 of file retry.c.

Function Documentation

◆ _entry_cmp()

static int8_t _entry_cmp ( void const *  one,
void const *  two 
)
static

Definition at line 745 of file retry.c.

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

◆ fr_bio_retry_alloc()

fr_bio_t* fr_bio_retry_alloc ( TALLOC_CTX *  ctx,
size_t  max_saved,
fr_bio_retry_sent_t  sent,
fr_bio_retry_response_t  response,
fr_bio_retry_rewrite_t  rewrite,
fr_bio_retry_release_t  release,
fr_bio_retry_config_t const *  cfg,
fr_bio_t next 
)

Allocate a fr_bio_retry_t.

Definition at line 852 of file retry.c.

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

◆ fr_bio_retry_blocked()

static ssize_t fr_bio_retry_blocked ( fr_bio_retry_t my,
fr_bio_retry_entry_t item,
ssize_t  rcode 
)
static

The write is blocked.

We couldn't write out the entire packet, the bio is blocked. Don't write anything else until we become unblocked!

And free the timer. There's no point in trying to write things if the socket is blocked.

Definition at line 396 of file retry.c.

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

◆ fr_bio_retry_destructor()

static int fr_bio_retry_destructor ( fr_bio_retry_t my)
static

Cancel all outstanding packets.

Definition at line 829 of file retry.c.

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

◆ fr_bio_retry_entry_cancel()

int fr_bio_retry_entry_cancel ( fr_bio_t bio,
fr_bio_retry_entry_t item 
)

Cancel one item.

If "item" is NULL, the last entry in the timer tree is cancelled.

Parameters
biothe binary IO handler
itemthe retry context from fr_bio_retry_sent_t
Returns
  • <0 error
  • 0 - didn't cancel
  • 1 - did cancel

Definition at line 767 of file retry.c.

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

◆ fr_bio_retry_entry_info()

const fr_retry_t* fr_bio_retry_entry_info ( UNUSED fr_bio_t bio,
fr_bio_retry_entry_t item 
)

Allow the callbacks / application to know when things are being retried.

This is not initialized util after fr_bio_retry_entry_start() has been called.

Definition at line 816 of file retry.c.

+ Here is the call graph for this function:

◆ fr_bio_retry_entry_start()

int fr_bio_retry_entry_start ( UNUSED fr_bio_t bio,
fr_bio_retry_entry_t item,
fr_retry_config_t const *  cfg 
)

Set a per-packet retry config.

This function should be called from the fr_bio_retry_sent_t callback to set a unique retry timer for this packet. If no retry configuration is set, then the main one from the alloc() function is used.

Definition at line 799 of file retry.c.

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

◆ fr_bio_retry_read()

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

Definition at line 674 of file retry.c.

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

◆ fr_bio_retry_release()

static void fr_bio_retry_release ( fr_bio_retry_t my,
fr_bio_retry_entry_t item,
fr_bio_retry_release_reason_t  reason 
)
static

Release an entry back to the free list.

Definition at line 146 of file retry.c.

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

◆ fr_bio_retry_reset_timer()

static int fr_bio_retry_reset_timer ( fr_bio_retry_t my)
static

Reset the timer after changing the rb tree.

Definition at line 108 of file retry.c.

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

◆ fr_bio_retry_rewrite()

ssize_t fr_bio_retry_rewrite ( fr_bio_t bio,
fr_bio_retry_entry_t item,
const void *  buffer,
size_t  size 
)

Resend a packet.

This function should be called by the rewrite() callback, after (possibly) re-encoding the packet.

Parameters
biothe binary IO handler
itemthe retry context from fr_bio_retry_sent_t
bufferraw data for the packet. May be NULL, in which case the previous packet is retried
sizesize of the raw data
Returns
  • <0 on error
  • 0 for "wrote no data"
  • >0 for "wrote data".

Definition at line 447 of file retry.c.

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

◆ fr_bio_retry_timer()

static void fr_bio_retry_timer ( UNUSED fr_event_list_t el,
fr_time_t  now,
void *  uctx 
)
static

Run a timer event.

Usually to write out another packet.

Definition at line 519 of file retry.c.

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

◆ fr_bio_retry_write()

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

Write a request, and see if we have a reply.

Definition at line 563 of file retry.c.

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

◆ fr_bio_retry_write_delayed()

static int fr_bio_retry_write_delayed ( fr_bio_retry_t my,
fr_time_t  now 
)
static

Definition at line 255 of file retry.c.

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

◆ fr_bio_retry_write_fatal()

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

A previous timer write had a fatal error, so we forbid further writes.

Definition at line 509 of file retry.c.

+ Here is the caller graph for this function:

◆ fr_bio_retry_write_item()

static int fr_bio_retry_write_item ( fr_bio_retry_t my,
fr_bio_retry_entry_t item,
fr_time_t  now 
)
static

Write one item.

Returns
  • <0 on error
  • 0 for "can't write any more"
  • 1 for "wrote a packet"

Definition at line 190 of file retry.c.

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

◆ fr_bio_retry_write_partial()

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

There's a partial packet written.

Write all of that one first, before writing another packet.

The packet can either be cancelled, or IO blocked. In either case, we must write the full packet before going on to the next one, OR retrying another packet.

Definition at line 298 of file retry.c.

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