]> jfr.im git - irc/rqf/shadowircd.git/blobdiff - src/hash.c
Disable autoconnect for a server with excessive TS delta.
[irc/rqf/shadowircd.git] / src / hash.c
index 980153027209632783a5d11bcec80fd838d7001c..10e35066d83ef9088e2a4644a43e796aa9223235 100644 (file)
@@ -31,7 +31,7 @@
 #include "client.h"
 #include "common.h"
 #include "hash.h"
-#include "irc_string.h"
+#include "match.h"
 #include "ircd.h"
 #include "numeric.h"
 #include "send.h"
 #include "cache.h"
 #include "s_newconf.h"
 
+#define hash_cli_fd(x) (x % CLI_FD_MAX)
+
+static rb_dlink_list clientbyfdTable[U_MAX];
+
 rb_dlink_list *clientTable;
 rb_dlink_list *channelTable;
 rb_dlink_list *idTable;
@@ -660,35 +664,35 @@ clear_resv_hash(void)
        HASH_WALK_END
 }
 
-void\r
-add_to_cli_fd_hash(struct Client *client_p)\r
-{\r
-       rb_dlinkAddAlloc(client_p, &clientbyfdTable[hash_cli_fd(rb_get_fd(client_p->localClient->F))]);\r
-}\r
-\r
-\r
-void\r
-del_from_cli_fd_hash(struct Client *client_p)\r
-{\r
-       unsigned int hashv;\r
-       hashv = hash_cli_fd(rb_get_fd(client_p->localClient->F));\r
-       rb_dlinkFindDestroy(client_p, &clientbyfdTable[hashv]);\r
-}\r
-\r
-struct Client *\r
-find_cli_fd_hash(int fd)\r
-{\r
-       struct Client *target_p;\r
-       rb_dlink_node *ptr;\r
-       unsigned int hashv;\r
-       hashv = hash_cli_fd(fd);\r
-       RB_DLINK_FOREACH(ptr, clientbyfdTable[hashv].head)\r
-       {\r
-               target_p = ptr->data;\r
-               if(rb_get_fd(target_p->localClient->F) == fd)\r
-                       return target_p;\r
-       }\r
-       return  NULL;   \r
+void
+add_to_cli_fd_hash(struct Client *client_p)
+{
+       rb_dlinkAddAlloc(client_p, &clientbyfdTable[hash_cli_fd(rb_get_fd(client_p->localClient->F))]);
+}
+
+
+void
+del_from_cli_fd_hash(struct Client *client_p)
+{
+       unsigned int hashv;
+       hashv = hash_cli_fd(rb_get_fd(client_p->localClient->F));
+       rb_dlinkFindDestroy(client_p, &clientbyfdTable[hashv]);
+}
+
+struct Client *
+find_cli_fd_hash(int fd)
+{
+       struct Client *target_p;
+       rb_dlink_node *ptr;
+       unsigned int hashv;
+       hashv = hash_cli_fd(fd);
+       RB_DLINK_FOREACH(ptr, clientbyfdTable[hashv].head)
+       {
+               target_p = ptr->data;
+               if(rb_get_fd(target_p->localClient->F) == fd)
+                       return target_p;
+       }
+       return  NULL;   
 }
 
 static void
@@ -696,14 +700,16 @@ output_hash(struct Client *source_p, const char *name, int length, int *counts,
 {
        unsigned long total = 0;
        int i;
+       char buf[128];
 
        sendto_one_numeric(source_p, RPL_STATSDEBUG,
                        "B :%s Hash Statistics", name);
 
-       sendto_one_numeric(source_p, RPL_STATSDEBUG,
-                       "B :Size: %d Empty: %d (%.3f%%)",
-                       length, counts[0], 
+       snprintf(buf, sizeof buf, "%.3f%%",
                        (float) ((counts[0]*100) / (float) length));
+       sendto_one_numeric(source_p, RPL_STATSDEBUG,
+                       "B :Size: %d Empty: %d (%s)",
+                       length, counts[0], buf);
 
        for(i = 1; i < 11; i++)
        {
@@ -712,10 +718,14 @@ output_hash(struct Client *source_p, const char *name, int length, int *counts,
 
        /* dont want to divide by 0! --fl */
        if(counts[0] != length)
-               sendto_one_numeric(source_p, RPL_STATSDEBUG,
-                               "B :Average depth: %.3f/%.3f Highest depth: %d",
+       {
+               snprintf(buf, sizeof buf, "%.3f/%.3f",
                                (float) (total / (length - counts[0])),
-                               (float) (total / length), deepest);
+                               (float) (total / length));
+               sendto_one_numeric(source_p, RPL_STATSDEBUG,
+                               "B :Average depth: %s Highest depth: %d",
+                               buf, deepest);
+       }
 
        for(i = 0; i < 11; i++)
        {