37 |
#include "config.h" |
#include "config.h" |
38 |
#include "memory.h" |
#include "memory.h" |
39 |
#include "log.h" |
#include "log.h" |
40 |
|
#include "opm_gettime.h" |
41 |
|
|
42 |
|
|
43 |
extern unsigned int OPT_DEBUG; |
extern unsigned int OPT_DEBUG; |
73 |
{ |
{ |
74 |
struct negcache_item *n = pnode->data; |
struct negcache_item *n = pnode->data; |
75 |
|
|
76 |
if (time(NULL) - n->seen <= OptionsItem.negcache) |
if (opm_gettime() - n->seen <= OptionsItem.negcache) |
77 |
return n; |
return n; |
78 |
} |
} |
79 |
|
|
92 |
return; /* Malformed IP address or already added to the trie */ |
return; /* Malformed IP address or already added to the trie */ |
93 |
|
|
94 |
struct negcache_item *n = xcalloc(sizeof(*n)); |
struct negcache_item *n = xcalloc(sizeof(*n)); |
95 |
n->seen = time(NULL); |
n->seen = opm_gettime(); |
96 |
|
|
97 |
pnode->data = n; |
pnode->data = n; |
98 |
list_add(pnode, &n->node, &negcache_list); |
list_add(pnode, &n->node, &negcache_list); |
105 |
negcache_rebuild(void) |
negcache_rebuild(void) |
106 |
{ |
{ |
107 |
node_t *node, *node_next; |
node_t *node, *node_next; |
108 |
|
time_t present = opm_gettime(); |
109 |
|
|
110 |
LIST_FOREACH_SAFE(node, node_next, negcache_list.head) |
LIST_FOREACH_SAFE(node, node_next, negcache_list.head) |
111 |
{ |
{ |
112 |
patricia_node_t *pnode = node->data; |
patricia_node_t *pnode = node->data; |
113 |
struct negcache_item *n = pnode->data; |
struct negcache_item *n = pnode->data; |
114 |
|
|
115 |
if (n->seen + OptionsItem.negcache < time(NULL)) |
if (n->seen + OptionsItem.negcache < present) |
116 |
{ |
{ |
117 |
if (OPT_DEBUG >= 2) |
if (OPT_DEBUG >= 2) |
118 |
log_printf("NEGCACHE -> Deleting expired negcache node for %s added at %lu", |
log_printf("NEGCACHE -> Deleting expired negcache node for %s added at %lu", |