/[svn]/hopm/trunk/src/negcache.c
ViewVC logotype

Diff of /hopm/trunk/src/negcache.c

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 9861 by michael, Wed Jan 1 10:03:28 2020 UTC revision 9862 by michael, Sat Jan 2 18:39:00 2021 UTC
# Line 37  Line 37 
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;
# Line 72  negcache_check(const char *ipstr) Line 73  negcache_check(const char *ipstr)
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    
# Line 91  negcache_insert(const char *ipstr) Line 92  negcache_insert(const char *ipstr)
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);
# Line 104  void Line 105  void
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",

Legend:
Removed from v.9861  
changed lines
  Added in v.9862

svnadmin@ircd-hybrid.org
ViewVC Help
Powered by ViewVC 1.1.28