The FreeRADIUS server $Id: 15bac2a4c627c01d1aa2047687b3418955ac7f00 $
Loading...
Searching...
No Matches
rb_expire.h
Go to the documentation of this file.
1#pragma once
2/*
3 * This program is free software; you can redistribute it and/or modify
4 * it under the terms of the GNU General Public License as published by
5 * the Free Software Foundation; either version 2 of the License, or
6 * (at your option) any later version.
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
12 *
13 * You should have received a copy of the GNU General Public License
14 * along with this program; if not, write to the Free Software
15 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
16 */
17
18/** RB trees with expiry timers
19 *
20 * @file src/lib/util/rb_expire.h
21 *
22 * @copyright 2024 Network RADIUS SAS (legal@networkradius.com)
23 */
24RCSIDH(fr_rb_expire_h, "$Id: 5789be97b2c4dbf2276a396a2975bbf357aceac1 $")
25
26#ifdef __cplusplus
27extern "C" {
28#endif
29
30#include <freeradius-devel/util/rb.h>
31#include <freeradius-devel/util/dlist.h>
32
39
40/** dlist for expiring old entries
41 *
42 * This structure should be inside of the
43 */
49
50#define fr_rb_expire_inline_talloc_init(_expire, _type, _field, _data_cmp, _data_free, _lifetime) \
51 do { \
52 fr_rb_inline_talloc_init(&(_expire)->tree, _type, _field.node, _data_cmp, _data_free); \
53 fr_dlist_init(&(_expire)->head, _type, _field.entry); \
54 (_expire)->lifetime = _lifetime; \
55 (_expire)->last_expiry = fr_time(); \
56 } while (0)
57
58bool fr_rb_expire_insert(fr_rb_expire_t *expire, void *data, fr_time_t now) CC_HINT(nonnull);
59
60void fr_rb_expire_update(fr_rb_expire_t *expire, void *data, fr_time_t now) CC_HINT(nonnull);
61
62#ifdef __cplusplus
63}
64#endif
#define RCSIDH(h, id)
Definition build.h:484
Head of a doubly linked list.
Definition dlist.h:51
Entry in a doubly linked list.
Definition dlist.h:41
The main red black tree structure.
Definition rb.h:73
fr_dlist_t entry
Definition rb_expire.h:46
fr_rb_node_t node
Definition rb_expire.h:45
fr_dlist_head_t head
Definition rb_expire.h:35
bool fr_rb_expire_insert(fr_rb_expire_t *expire, void *data, fr_time_t now)
Attempt to find current data in the tree, if it does not exist insert it.
Definition rb_expire.c:39
void fr_rb_expire_update(fr_rb_expire_t *expire, void *data, fr_time_t now)
Definition rb_expire.c:55
fr_time_delta_t lifetime
Definition rb_expire.h:36
fr_time_t last_expiry
Definition rb_expire.h:37
fr_rb_tree_t tree
Definition rb_expire.h:34
dlist for expiring old entries
Definition rb_expire.h:44
A time delta, a difference in time measured in nanoseconds.
Definition time.h:80
"server local" time.
Definition time.h:69
static fr_slen_t data
Definition value.h:1265
int nonnull(2, 5))