ViewVC Help
View File | Revision Log | Show Annotations | View Changeset | Root Listing
root/svn/branches/ircd-hybrid-newconf/modules/m_hash.c
Revision: 1027
Committed: Sun Nov 8 13:01:13 2009 UTC (16 years, 9 months ago) by michael
Content type: text/x-csrc
File size: 4494 byte(s)
Log Message:
- Move old 7.3 sources to branches/ircd-hybrid-newconf

File Contents

# Content
1 /*
2 * ircd-hybrid: an advanced Internet Relay Chat Daemon(ircd).
3 *
4 * Copyright (C) 2002 by the past and present ircd coders, and others.
5 *
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version.
10 *
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
19 * USA
20 *
21 * $Id$
22 */
23
24 #include "stdinc.h"
25 #include "handlers.h"
26 #include "channel.h"
27 #include "channel_mode.h"
28 #include "client.h"
29 #include "hash.h"
30 #include "ircd.h"
31 #include "numeric.h"
32 #include "server.h"
33 #include "send.h"
34 #include "msg.h"
35 #include "parse.h"
36 #include "conf/modules.h"
37 #include "user.h"
38 #include "userhost.h"
39
40 static void mo_hash(struct Client *, struct Client *, int, char *[]);
41
42 struct Message hash_msgtab = {
43 "HASH", 0, 0, 0, 0, MFLG_SLOW, 0,
44 { m_unregistered, m_not_oper, m_ignore, m_ignore, mo_hash, m_ignore }
45 };
46
47 INIT_MODULE(m_hash, "$Revision$")
48 {
49 mod_add_cmd(&hash_msgtab);
50 }
51
52 CLEANUP_MODULE
53 {
54 mod_del_cmd(&hash_msgtab);
55 }
56
57 /*! \brief HASH command handler (called for operators only)
58 *
59 * Returns various information such as maxmimum entries, slots that
60 * are in use and collision count
61 *
62 * \param client_p Pointer to allocated Client struct with physical connection
63 * to this server, i.e. with an open socket connected.
64 * \param source_p Pointer to allocated Client struct from which the message
65 * originally comes from. This can be a local or remote client.
66 * \param parc Integer holding the number of supplied arguments.
67 * \param parv Argument vector where parv[0] .. parv[parc-1] are non-NULL
68 * pointers.
69 * \note Valid arguments for this command are:
70 * - parv[0] = sender prefix
71 */
72 static void
73 mo_hash(struct Client *client_p, struct Client *source_p,
74 int parc, char *parv[])
75 {
76 int i;
77 int max_chain = 0;
78 int buckets = 0;
79 int count = 0;
80 struct Client *cl;
81 struct Client *icl;
82 struct Channel *ch;
83 struct UserHost *ush;
84
85 for (i = 0; i < HASHSIZE; ++i)
86 {
87 if ((cl = hash_get_bucket(HASH_TYPE_CLIENT, i)) != NULL)
88 {
89 int len = 0;
90
91 ++buckets;
92 for (; cl != NULL; cl = cl->hnext)
93 ++len;
94 if (len > max_chain)
95 max_chain = len;
96 count += len;
97 }
98 }
99
100 sendto_one(source_p, ":%s NOTICE %s :Client: entries: %d buckets: %d "
101 "max chain: %d", me.name, source_p->name, count, buckets,
102 max_chain);
103
104 count = 0;
105 buckets = 0;
106 max_chain = 0;
107
108 for (i = 0; i < HASHSIZE; ++i)
109 {
110 if ((ch = hash_get_bucket(HASH_TYPE_CHANNEL, i)) != NULL)
111 {
112 int len = 0;
113
114 ++buckets;
115 for (; ch != NULL; ch = ch->hnextch)
116 ++len;
117 if (len > max_chain)
118 max_chain = len;
119 count += len;
120 }
121 }
122
123 sendto_one(source_p, ":%s NOTICE %s :Channel: entries: %d buckets: %d "
124 "max chain: %d", me.name, source_p->name, count, buckets,
125 max_chain);
126
127 count = 0;
128 buckets = 0;
129 max_chain = 0;
130
131 for (i = 0; i < HASHSIZE; ++i)
132 {
133 if ((icl = hash_get_bucket(HASH_TYPE_ID, i)) != NULL)
134 {
135 int len = 0;
136
137 ++buckets;
138 for (; icl != NULL; icl = icl->idhnext)
139 ++len;
140 if (len > max_chain)
141 max_chain = len;
142 count += len;
143 }
144 }
145
146 sendto_one(source_p, ":%s NOTICE %s :Id: entries: %d buckets: %d "
147 "max chain: %d", me.name, source_p->name, count, buckets,
148 max_chain);
149
150 count = 0;
151 buckets = 0;
152 max_chain = 0;
153
154 for (i = 0; i < HASHSIZE; ++i)
155 {
156 if ((ush = hash_get_bucket(HASH_TYPE_USERHOST, i)) != NULL)
157 {
158 int len = 0;
159
160 ++buckets;
161 for (; ush != NULL; ush = ush->next)
162 ++len;
163 if (len > max_chain)
164 max_chain = len;
165 count += len;
166 }
167 }
168
169 sendto_one(source_p, ":%s NOTICE %s :UserHost: entries: %d buckets: %d "
170 "max chain: %d", me.name, source_p->name, count, buckets,
171 max_chain);
172 }

Properties

Name Value
svn:eol-style native
svn:keywords Id Revision