ViewVC Help
View File | Revision Log | Show Annotations | View Changeset | Root Listing
root/svn/ircd-hybrid/trunk/src/conf_cluster.c
Revision: 7209
Committed: Wed Feb 3 15:10:39 2016 UTC (10 years, 8 months ago) by michael
Content type: text/x-csrc
File size: 2337 byte(s)
Log Message:
- Clustering has been broken in -r7159. Rewrote most of the shared/cluster implementation to be less obscure.
  This introduces a little bit of code duplication, but increases readability, is less error prone, and
  reduces memory consumption a bit.

File Contents

# User Rev Content
1 michael 7209 /*
2     * ircd-hybrid: an advanced, lightweight Internet Relay Chat Daemon (ircd)
3     *
4     * Copyright (c) 1997-2016 ircd-hybrid development team
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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301
19     * USA
20     */
21    
22     /*! \file conf_cluster.c
23     * \brief Implements cluster {} block configuration management.
24     * \version $Id: conf_cluster.c 7158 2016-01-28 11:25:55Z michael $
25     */
26    
27     #include "stdinc.h"
28     #include "list.h"
29     #include "ircd_defs.h"
30     #include "irc_string.h"
31     #include "memory.h"
32     #include "conf_cluster.h"
33     #include "client.h"
34     #include "server.h"
35     #include "send.h"
36    
37    
38     static dlink_list cluster_list;
39    
40    
41     const dlink_list *
42     cluster_get_list(void)
43     {
44     return &cluster_list;
45     }
46    
47     void
48     cluster_clear(void)
49     {
50     while (cluster_list.head)
51     {
52     struct ClusterItem *cluster = cluster_list.head->data;
53    
54     dlinkDelete(&cluster->node, &cluster_list);
55     xfree(cluster->server);
56     xfree(cluster);
57     }
58     }
59    
60     struct ClusterItem *
61     cluster_make(void)
62     {
63     struct ClusterItem *cluster = xcalloc(sizeof(*cluster));
64     dlinkAdd(cluster, &cluster->node, &cluster_list);
65    
66     return cluster;
67     }
68    
69     void
70     cluster_distribute(struct Client *source_p, const char *command, unsigned int capab,
71     unsigned int type, const char *pattern, ...)
72     {
73     va_list args;
74     char buffer[IRCD_BUFSIZE] = "";
75     dlink_node *node;
76    
77     va_start(args, pattern);
78     vsnprintf(buffer, sizeof(buffer), pattern, args);
79     va_end(args);
80    
81     DLINK_FOREACH(node, cluster_list.head)
82     {
83     const struct ClusterItem *cluster = node->data;
84    
85     if (cluster->type & type)
86     sendto_match_servs(source_p, cluster->server, CAPAB_CLUSTER | capab,
87     "%s %s %s", command, cluster->server, buffer);
88     }
89     }