]> jfr.im git - solanum.git/commitdiff
ircd: ensure irc_dictionary users have names, for stats tracking.
authorWilliam Pitcock <redacted>
Sat, 9 Jan 2016 07:22:11 +0000 (01:22 -0600)
committerWilliam Pitcock <redacted>
Sat, 9 Jan 2016 07:22:11 +0000 (01:22 -0600)
include/irc_dictionary.h
ircd/cache.c
ircd/capability.c
ircd/client.c
ircd/irc_dictionary.c
ircd/parse.c
ircd/s_conf.c
modules/m_stats.c

index 69f3babc60f64c54d6bded58ffb65605fdfc6269..e5dd6a74476e87e7b5f004806b2c0bbd8b37d8ae 100644 (file)
@@ -47,18 +47,11 @@ struct DictionaryIter
  */
 #define DICTIONARY_FOREACH(element, state, dict) for (irc_dictionary_foreach_start((dict), (state)); (element = irc_dictionary_foreach_cur((dict), (state))); irc_dictionary_foreach_next((dict), (state)))
 
-/*
- * irc_dictionary_create() creates a new dictionary tree.
- * compare_cb is the comparison function, typically strcmp, strcasecmp or
- * irccasecmp.
- */
-extern struct Dictionary *irc_dictionary_create(DCF compare_cb);
-
 /*
  * irc_dictionary_create_named() creates a new dictionary tree which has a name.
  * name is the name, compare_cb is the comparator.
  */
-extern struct Dictionary *irc_dictionary_create_named(const char *name, DCF compare_cb);
+extern struct Dictionary *irc_dictionary_create(const char *name, DCF compare_cb);
 
 /*
  * irc_dictionary_set_comparator_func() resets the comparator used for lookups and
index 88dab60d6e4908f2068a59749b97e330e73859c1..08e58b4ae312e9dd7a1045847a2c6c663c55fa5c 100644 (file)
@@ -71,8 +71,8 @@ init_cache(void)
        oper_motd = cache_file(OPATH, "opers.motd", 0);
        memset(&links_cache_list, 0, sizeof(links_cache_list));
 
-       help_dict_oper = irc_dictionary_create(strcasecmp);
-       help_dict_user = irc_dictionary_create(strcasecmp);
+       help_dict_oper = irc_dictionary_create("oper help", strcasecmp);
+       help_dict_user = irc_dictionary_create("user help", strcasecmp);
 }
 
 /*
index daf72657bdb98e8556d04784f0c4af27fbc38390..075c0d41168a94648655e8eb0ca8afb01e7261d2 100644 (file)
@@ -143,7 +143,7 @@ capability_index_create(const char *name)
 
        idx = rb_malloc(sizeof(struct CapabilityIndex));
        idx->name = rb_strdup(name);
-       idx->cap_dict = irc_dictionary_create(strcasecmp);
+       idx->cap_dict = irc_dictionary_create(name, strcasecmp);
        idx->highest_bit = 1;
 
        rb_dlinkAdd(idx, &idx->node, &capability_indexes);
index 39d4ea4d839e7d29d5b0568a6f0e3ea6143d5e3d..2fc1f22604fc210d6dff100cf342306c15669a6c 100644 (file)
@@ -129,7 +129,7 @@ init_client(void)
        rb_event_addish("exit_aborted_clients", exit_aborted_clients, NULL, 1);
        rb_event_add("flood_recalc", flood_recalc, NULL, 1);
 
-       nd_dict = irc_dictionary_create(irccmp);
+       nd_dict = irc_dictionary_create("nickdelay", irccmp);
 }
 
 
index 36a690549299b50b46d5f7ad02b36ad3e1614af8..8bfd4ad88075fa311b209772128d14aa66bae134 100644 (file)
@@ -30,8 +30,6 @@
 #include "s_assert.h"
 #include "logger.h"
 
-static rb_bh *elem_heap = NULL;
-
 struct Dictionary
 {
        DCF compare_cb;
@@ -42,35 +40,7 @@ struct Dictionary
 };
 
 /*
- * irc_dictionary_create(DCF compare_cb)
- *
- * Dictionary object factory.
- *
- * Inputs:
- *     - function to use for comparing two entries in the dtree
- *
- * Outputs:
- *     - on success, a new dictionary object.
- *
- * Side Effects:
- *     - if services runs out of memory and cannot allocate the object,
- *       the program will abort.
- */
-struct Dictionary *irc_dictionary_create(DCF compare_cb)
-{
-       struct Dictionary *dtree = (struct Dictionary *) rb_malloc(sizeof(struct Dictionary));
-
-       dtree->compare_cb = compare_cb;
-
-       if (!elem_heap)
-               elem_heap = rb_bh_create(sizeof(struct DictionaryElement), 1024, "dictionary_elem_heap");
-
-       return dtree;
-}
-
-/*
- * irc_dictionary_create_named(const char *name,
- *     DCF compare_cb)
+ * irc_dictionary_create(const char *name, DCF compare_cb)
  *
  * Dictionary object factory.
  *
@@ -85,7 +55,7 @@ struct Dictionary *irc_dictionary_create(DCF compare_cb)
  *     - if services runs out of memory and cannot allocate the object,
  *       the program will abort.
  */
-struct Dictionary *irc_dictionary_create_named(const char *name,
+struct Dictionary *irc_dictionary_create(const char *name,
        DCF compare_cb)
 {
        struct Dictionary *dtree = (struct Dictionary *) rb_malloc(sizeof(struct Dictionary));
@@ -93,9 +63,6 @@ struct Dictionary *irc_dictionary_create_named(const char *name,
        dtree->compare_cb = compare_cb;
        dtree->id = rb_strdup(name);
 
-       if (!elem_heap)
-               elem_heap = rb_bh_create(sizeof(struct DictionaryElement), 1024, "dictionary_elem_heap");
-
        return dtree;
 }
 
@@ -365,7 +332,7 @@ irc_dictionary_link(struct Dictionary *dict,
                        dict->root->data = delem->data;
                        dict->count--;
 
-                       rb_bh_free(elem_heap, delem);
+                       rb_free(delem);
                }
        }
 }
@@ -474,7 +441,7 @@ void irc_dictionary_destroy(struct Dictionary *dtree,
                if (destroy_cb != NULL)
                        (*destroy_cb)(n, privdata);
 
-               rb_bh_free(elem_heap, n);
+               rb_free(n);
        }
 
        rb_free(dtree);
@@ -714,14 +681,14 @@ struct DictionaryElement *irc_dictionary_add(struct Dictionary *dict, const char
        s_assert(data != NULL);
        s_assert(irc_dictionary_find(dict, key) == NULL);
 
-       delem = rb_bh_alloc(elem_heap);
+       delem = rb_malloc(sizeof(*delem));
        delem->key = key;
        delem->data = data;
 
        /* TBD: is this needed? --nenolod */
        if (delem->key == NULL)
        {
-               rb_bh_free(elem_heap, delem);
+               rb_free(delem);
                return NULL;
        }
 
@@ -760,7 +727,7 @@ void *irc_dictionary_delete(struct Dictionary *dtree, const char *key)
        data = delem->data;
 
        irc_dictionary_unlink_root(dtree);
-       rb_bh_free(elem_heap, delem);
+       rb_free(delem);
 
        return data;
 }
index 190c9f08a10263533e197bdce80cc2cfba16a800..84132c82d44d6ed9e277c61710f6422e8ae91ea0 100644 (file)
@@ -407,7 +407,7 @@ handle_encap(struct Client *client_p, struct Client *source_p,
 void
 clear_hash_parse()
 {
-       cmd_dict = irc_dictionary_create(strcasecmp);
+       cmd_dict = irc_dictionary_create("command", strcasecmp);
 }
 
 /* mod_add_cmd
index 0587f328934bfd084f04dd8aa79ad71b9ebaf047..ebd6919bb8fc6a82da5c1d69de3b3c5f71e34b06 100644 (file)
@@ -826,7 +826,7 @@ set_default_conf(void)
        ConfigFileEntry.certfp_method = RB_SSL_CERTFP_METH_SHA1;
 
        if (!alias_dict)
-               alias_dict = irc_dictionary_create(strcasecmp);
+               alias_dict = irc_dictionary_create("alias", strcasecmp);
 }
 
 #undef YES
index ed8d0077f1cba49189238f5ee73f4f2698d485ed..c37bd6b33ab114cb8f1a963fe6cce9f866a1c4d1 100644 (file)
@@ -48,6 +48,7 @@
 #include "hash.h"
 #include "reject.h"
 #include "whowas.h"
+#include "irc_radixtree.h"
 
 static int m_stats (struct Client *, struct Client *, int, const char **);