ratelimiter.h File Reference

A rate limiter is a mechanism for dispatching events at a limited rate. This is intended to be used when sending zone maintenance SOA queries, NOTIFY messages, etc. More...

#include <isc/lang.h>
#include <isc/types.h>

Go to the source code of this file.

Defines

#define ISC_RATELIMITER_H   1

Functions

ISC_LANG_BEGINDECLS isc_result_t isc_ratelimiter_create (isc_mem_t *mctx, isc_timermgr_t *timermgr, isc_task_t *task, isc_ratelimiter_t **ratelimiterp)
 Create a rate limiter. The execution interval is initially undefined.
isc_result_t isc_ratelimiter_setinterval (isc_ratelimiter_t *rl, isc_interval_t *interval)
void isc_ratelimiter_setpertic (isc_ratelimiter_t *rl, isc_uint32_t perint)
 Set the number of events processed per interval timer tick. If 'perint' is zero it is treated as 1.
isc_result_t isc_ratelimiter_enqueue (isc_ratelimiter_t *rl, isc_task_t *task, isc_event_t **eventp)
 Queue an event for rate-limited execution.
isc_result_t isc_ratelimiter_dequeue (isc_ratelimiter_t *rl, isc_event_t *event)
void isc_ratelimiter_shutdown (isc_ratelimiter_t *ratelimiter)
 Shut down a rate limiter.
void isc_ratelimiter_attach (isc_ratelimiter_t *source, isc_ratelimiter_t **target)
 Attach to a rate limiter.
void isc_ratelimiter_detach (isc_ratelimiter_t **ratelimiterp)
 Detach from a rate limiter.
isc_result_t isc_ratelimiter_stall (isc_ratelimiter_t *rl)
 Stall event processing.
isc_result_t isc_ratelimiter_release (isc_ratelimiter_t *rl)
 Release a stalled rate limiter.


Detailed Description

A rate limiter is a mechanism for dispatching events at a limited rate. This is intended to be used when sending zone maintenance SOA queries, NOTIFY messages, etc.

Definition in file ratelimiter.h.


Define Documentation

#define ISC_RATELIMITER_H   1

Definition at line 21 of file ratelimiter.h.


Function Documentation

ISC_LANG_BEGINDECLS isc_result_t isc_ratelimiter_create ( isc_mem_t mctx,
isc_timermgr_t timermgr,
isc_task_t task,
isc_ratelimiter_t **  ratelimiterp 
)

Create a rate limiter. The execution interval is initially undefined.

Definition at line 60 of file ratelimiter.c.

References DESTROYLOCK, INSIST, isc_ratelimiter::interval, ISC_EVENT_INIT, isc_interval_set(), ISC_LIST_INIT, isc_mem_get, isc_mem_put, isc_mutex_init, ISC_R_NOMEMORY, ISC_R_SUCCESS, isc_ratelimiter_idle, ISC_RATELIMITEREVENT_SHUTDOWN, isc_timer_create(), isc_timertype_inactive, isc_ratelimiter::lock, isc_ratelimiter::mctx, isc_ratelimiter::pertic, ratelimiter_shutdowncomplete(), ratelimiter_tick(), isc_ratelimiter::refs, isc_ratelimiter::shutdownevent, isc_ratelimiter::state, isc_ratelimiter::task, and isc_ratelimiter::timer.

Referenced by dns_zonemgr_create().

isc_result_t isc_ratelimiter_setinterval ( isc_ratelimiter_t rl,
isc_interval_t interval 
)

Set the minimum interval between event executions. The interval value is copied, so the caller need not preserve it.

Requires: '*interval' is a nonzero interval.

Definition at line 111 of file ratelimiter.c.

References isc_ratelimiter::interval, ISC_FALSE, ISC_R_SUCCESS, isc_ratelimiter_ratelimited, isc_timer_reset(), isc_timertype_ticker, isc_ratelimiter::lock, LOCK, REQUIRE, isc_ratelimiter::state, isc_ratelimiter::timer, and UNLOCK.

Referenced by setrl().

void isc_ratelimiter_setpertic ( isc_ratelimiter_t rl,
isc_uint32_t  perint 
)

Set the number of events processed per interval timer tick. If 'perint' is zero it is treated as 1.

Definition at line 131 of file ratelimiter.c.

References isc_ratelimiter::pertic, and REQUIRE.

Referenced by setrl().

isc_result_t isc_ratelimiter_enqueue ( isc_ratelimiter_t rl,
isc_task_t task,
isc_event_t **  eventp 
)

Queue an event for rate-limited execution.

This is similar to doing an isc_task_send() to the 'task', except that the execution may be delayed to achieve the desired rate of execution.

'(*eventp)->ev_sender' is used to hold the task. The caller must ensure that the task exists until the event is delivered.

Requires:

Definition at line 141 of file ratelimiter.c.

References INSIST, isc_ratelimiter::interval, ISC_FALSE, ISC_LIST_APPEND, ISC_R_SHUTTINGDOWN, ISC_R_SUCCESS, isc_ratelimiter_idle, isc_ratelimiter_ratelimited, isc_ratelimiter_shuttingdown, isc_ratelimiter_stalled, isc_task_send(), isc_timer_reset(), isc_timertype_ticker, isc_ratelimiter::lock, LOCK, REQUIRE, isc_ratelimiter::state, isc_ratelimiter::timer, and UNLOCK.

Referenced by notify_isqueued(), notify_send_queue(), and queue_soa_query().

isc_result_t isc_ratelimiter_dequeue ( isc_ratelimiter_t rl,
isc_event_t event 
)

Definition at line 177 of file ratelimiter.c.

References ISC_LINK_LINKED, ISC_LIST_UNLINK, ISC_R_NOTFOUND, ISC_R_SUCCESS, isc_ratelimiter::lock, LOCK, REQUIRE, and UNLOCK.

Referenced by notify_isqueued().

void isc_ratelimiter_shutdown ( isc_ratelimiter_t ratelimiter  ) 

Shut down a rate limiter.

Ensures:

Definition at line 236 of file ratelimiter.c.

References ISC_EVENTATTR_CANCELED, ISC_FALSE, ISC_LIST_HEAD, ISC_LIST_UNLINK, isc_ratelimiter_shuttingdown, isc_task_send(), isc_timer_detach(), isc_timer_reset(), isc_timertype_inactive, isc_ratelimiter::lock, LOCK, REQUIRE, isc_ratelimiter::shutdownevent, isc_ratelimiter::state, isc_ratelimiter::task, isc_ratelimiter::timer, and UNLOCK.

Referenced by dns_zonemgr_shutdown().

void isc_ratelimiter_attach ( isc_ratelimiter_t source,
isc_ratelimiter_t **  target 
)

Attach to a rate limiter.

Definition at line 280 of file ratelimiter.c.

References INSIST, isc_ratelimiter::lock, LOCK, isc_ratelimiter::refs, REQUIRE, and UNLOCK.

void isc_ratelimiter_detach ( isc_ratelimiter_t **  ratelimiterp  ) 

Detach from a rate limiter.

Definition at line 294 of file ratelimiter.c.

References free_now, ISC_FALSE, ISC_TRUE, isc_ratelimiter::lock, LOCK, ratelimiter_free(), isc_ratelimiter::refs, REQUIRE, and UNLOCK.

Referenced by dns_zonemgr_create(), ratelimiter_shutdowncomplete(), and zonemgr_free().

isc_result_t isc_ratelimiter_stall ( isc_ratelimiter_t rl  ) 

Stall event processing.

Definition at line 316 of file ratelimiter.c.

References ISC_FALSE, ISC_R_SHUTTINGDOWN, ISC_R_SUCCESS, isc_ratelimiter_idle, isc_ratelimiter_ratelimited, isc_ratelimiter_shuttingdown, isc_ratelimiter_stalled, isc_timer_reset(), isc_timertype_inactive, isc_ratelimiter::lock, LOCK, REQUIRE, RUNTIME_CHECK, isc_ratelimiter::state, isc_ratelimiter::timer, and UNLOCK.

isc_result_t isc_ratelimiter_release ( isc_ratelimiter_t rl  ) 

Release a stalled rate limiter.

Definition at line 341 of file ratelimiter.c.

References isc_ratelimiter::interval, ISC_FALSE, ISC_LIST_EMPTY, ISC_R_SHUTTINGDOWN, ISC_R_SUCCESS, isc_ratelimiter_idle, isc_ratelimiter_ratelimited, isc_ratelimiter_shuttingdown, isc_ratelimiter_stalled, isc_timer_reset(), isc_timertype_ticker, isc_ratelimiter::lock, LOCK, REQUIRE, isc_ratelimiter::state, isc_ratelimiter::timer, and UNLOCK.


Generated on Tue Apr 28 17:41:15 2015 by Doxygen 1.5.4 for BIND9 Internals 9.11.0pre-alpha