#include <config.h>#include <stddef.h>#include <isc/counter.h>#include <isc/magic.h>#include <isc/mem.h>#include <isc/util.h>Go to the source code of this file.
Data Structures | |
| struct | isc_counter |
Defines | |
| #define | COUNTER_MAGIC ISC_MAGIC('C', 'n', 't', 'r') |
| #define | VALID_COUNTER(r) ISC_MAGIC_VALID(r, COUNTER_MAGIC) |
Functions | |
| isc_result_t | isc_counter_create (isc_mem_t *mctx, int limit, isc_counter_t **counterp) |
| Allocate and initialize a counter object. | |
| isc_result_t | isc_counter_increment (isc_counter_t *counter) |
| Increment the counter. | |
| unsigned int | isc_counter_used (isc_counter_t *counter) |
| Return the current counter value. | |
| void | isc_counter_setlimit (isc_counter_t *counter, int limit) |
| Set the counter limit. | |
| void | isc_counter_attach (isc_counter_t *source, isc_counter_t **targetp) |
| Attach to a counter object, increasing its reference counter. | |
| static void | destroy (isc_counter_t *counter) |
| void | isc_counter_detach (isc_counter_t **counterp) |
| Detach (and destroy if reference counter has dropped to zero) a counter object. | |
Definition in file counter.c.
| #define COUNTER_MAGIC ISC_MAGIC('C', 'n', 't', 'r') |
Definition at line 29 of file counter.c.
Referenced by isc_counter_attach(), isc_counter_detach(), isc_counter_setlimit(), and isc_counter_used().
| isc_result_t isc_counter_create | ( | isc_mem_t * | mctx, | |
| int | limit, | |||
| isc_counter_t ** | counterp | |||
| ) |
Allocate and initialize a counter object.
Definition at line 41 of file counter.c.
References counter, COUNTER_MAGIC, isc_mem_attach(), isc_mem_get, isc_mem_put, isc_mutex_init, ISC_R_NOMEMORY, ISC_R_SUCCESS, isc_counter::limit, isc_counter::lock, isc_counter::magic, isc_counter::mctx, isc_counter::references, REQUIRE, and isc_counter::used.
Referenced by ATF_TC_BODY(), and fctx_create().
| isc_result_t isc_counter_increment | ( | isc_counter_t * | counter | ) |
Increment the counter.
If the counter limit is nonzero and has been reached, then return ISC_R_QUOTA, otherwise ISC_R_SUCCESS. (The counter is incremented regardless of return value.)
Definition at line 70 of file counter.c.
References ISC_R_QUOTA, ISC_R_SUCCESS, isc_counter::limit, isc_counter::lock, LOCK, UNLOCK, and isc_counter::used.
Referenced by ATF_TC_BODY(), and fctx_try().
| unsigned int isc_counter_used | ( | isc_counter_t * | counter | ) |
Return the current counter value.
Definition at line 83 of file counter.c.
References REQUIRE, isc_counter::used, and VALID_COUNTER.
Referenced by ATF_TC_BODY(), and fctx_try().
| void isc_counter_setlimit | ( | isc_counter_t * | counter, | |
| int | limit | |||
| ) |
Set the counter limit.
Definition at line 90 of file counter.c.
References isc_counter::limit, isc_counter::lock, LOCK, REQUIRE, UNLOCK, and VALID_COUNTER.
Referenced by ATF_TC_BODY().
| void isc_counter_attach | ( | isc_counter_t * | source, | |
| isc_counter_t ** | targetp | |||
| ) |
Attach to a counter object, increasing its reference counter.
Definition at line 99 of file counter.c.
References INSIST, isc_counter::lock, LOCK, isc_counter::references, REQUIRE, UNLOCK, and VALID_COUNTER.
Referenced by fctx_create().
| static void destroy | ( | isc_counter_t * | counter | ) | [static] |
Definition at line 112 of file counter.c.
References isc_mem_putanddetach, isc_mutex_destroy, isc_counter::lock, isc_counter::magic, and isc_counter::mctx.
Referenced by acache_cleaner_shutdown_action(), adb_shutdown(), authvalidated(), cleannode(), cnamevalidated(), detach(), dlvfetched(), dlvvalidated(), dns_acache_detach(), dns_acl_detach(), dns_dlzdestroy(), dns_keytable_detach(), dns_ntatable_detach(), dns_resolver_detach(), dns_ssutable_detach(), dns_tsigkeyring_dumpanddetach(), dns_validator_destroy(), dns_view_weakdetach(), doneloading(), dsfetched(), dsfetched2(), dsvalidated(), fetch_callback_validator(), internal_accept(), internal_connect(), isc___mem_putanddetach(), isc__socket_detach(), isc__timer_detach(), isc_counter_detach(), isc_entropy_destroysource(), isc_entropy_detach(), isc_event_allocate(), isc_event_constallocate(), isc_hash_ctxdetach(), isc_hash_destroy(), isc_rng_detach(), keyvalidated(), main(), notify_find_address(), ns_listenlist_detach(), req_shutdown(), resolver_shutdown(), shutdown_task(), validator_start(), view_flushanddetach(), and zt_flushanddetach().
| void isc_counter_detach | ( | isc_counter_t ** | counterp | ) |
Detach (and destroy if reference counter has dropped to zero) a counter object.
Definition at line 119 of file counter.c.
References counter, destroy(), INSIST, ISC_FALSE, ISC_TRUE, isc_counter::lock, LOCK, isc_counter::references, REQUIRE, UNLOCK, and VALID_COUNTER.
Referenced by ATF_TC_BODY(), fctx_create(), and fctx_destroy().