libwebsockets
Lightweight C library for HTML5 websockets
lws-retry.h File Reference
+ This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Data Structures

struct  lws_retry_bo
 

Macros

#define LWS_RETRY_CONCEAL_ALWAYS   (0xffff)
 

Typedefs

typedef struct lws_retry_bo lws_retry_bo_t
 

Functions

LWS_VISIBLE LWS_EXTERN unsigned int lws_retry_get_delay_ms (struct lws_context *context, const lws_retry_bo_t *retry, uint16_t *ctry, char *conceal)
 
LWS_VISIBLE LWS_EXTERN int lws_retry_sul_schedule (struct lws_context *context, int tid, lws_sorted_usec_list_t *sul, const lws_retry_bo_t *retry, sul_cb_t cb, uint16_t *ctry)
 
LWS_VISIBLE LWS_EXTERN int lws_retry_sul_schedule_retry_wsi (struct lws *wsi, lws_sorted_usec_list_t *sul, sul_cb_t cb, uint16_t *ctry)
 

Data Structure Documentation

◆ lws_retry_bo

struct lws_retry_bo

Definition at line 25 of file lws-retry.h.

+ Collaboration diagram for lws_retry_bo:
Data Fields
const uint32_t * retry_ms_table
uint16_t retry_ms_table_count
uint16_t conceal_count
uint16_t secs_since_valid_ping
uint16_t secs_since_valid_hangup
uint8_t jitter_percent

Macro Definition Documentation

◆ LWS_RETRY_CONCEAL_ALWAYS

#define LWS_RETRY_CONCEAL_ALWAYS   (0xffff)

Definition at line 34 of file lws-retry.h.

Typedef Documentation

◆ lws_retry_bo_t

typedef struct lws_retry_bo lws_retry_bo_t

Function Documentation

◆ lws_retry_get_delay_ms()

LWS_VISIBLE LWS_EXTERN unsigned int lws_retry_get_delay_ms ( struct lws_context *  context,
const lws_retry_bo_t retry,
uint16_t ctry,
char *  conceal 
)

lws_retry_get_delay_ms() - get next delay from backoff table

Parameters
lws_contextthe lws context (used for getting random)
retrythe retry backoff table we are using, or NULL for default
ctrypointer to the try counter
concealpointer to flag set to nonzero if the try should be concealed in terms of creating an error

Increments *try and retruns the number of ms that should elapse before the next connection retry, according to the backoff table retry. *conceal is set if the number of tries is less than the backoff table conceal_count, or is zero if it exceeded it. This lets you conceal a certain number of retries before alerting the caller there is a problem.

If retry is NULL, a default of 3s + (0..300ms jitter) is used. If it's non-NULL but jitter_percent is 0, the default of 30% jitter is retained.

◆ lws_retry_sul_schedule()

LWS_VISIBLE LWS_EXTERN int lws_retry_sul_schedule ( struct lws_context *  context,
int  tid,
lws_sorted_usec_list_t sul,
const lws_retry_bo_t retry,
sul_cb_t  cb,
uint16_t ctry 
)

lws_retry_sul_schedule() - schedule a sul according to the backoff table

Parameters
lws_contextthe lws context (used for getting random)
sulpointer to the sul to schedule
retrythe retry backoff table we are using, or NULL for default
cbthe callback for when the sul schedule time arrives
ctrypointer to the try counter

Helper that combines interpreting the retry table with scheduling a sul to the computed delay. If conceal is not set, it will not schedule the sul and just return 1. Otherwise the sul is scheduled and it returns 0.

◆ lws_retry_sul_schedule_retry_wsi()

LWS_VISIBLE LWS_EXTERN int lws_retry_sul_schedule_retry_wsi ( struct lws *  wsi,
lws_sorted_usec_list_t sul,
sul_cb_t  cb,
uint16_t ctry 
)

lws_retry_sul_schedule_retry_wsi() - retry sul schedule helper using wsi

Parameters
wsithe wsi to set the hrtimer sul on to the next retry interval
sulpointer to the sul to schedule
cbthe callback for when the sul schedule time arrives
ctrypointer to the try counter

Helper that uses context, tid and retry policy from a wsi to call lws_retry_sul_schedule.

Since a udp connection can have many writes in flight, the retry count and the sul used to track each thing that wants to be written have to be handled individually, not the wsi. But the retry policy and the other things can be filled in from the wsi conveniently.