… | |
… | |
8 | * Portions of this file were derived from sources bearing the following license: |
8 | * Portions of this file were derived from sources bearing the following license: |
9 | * Rights to this code are documented in doc/pod/license.pod. |
9 | * Rights to this code are documented in doc/pod/license.pod. |
10 | * Copyright © 2005-2007 Atheme Project (http://www.atheme.org) |
10 | * Copyright © 2005-2007 Atheme Project (http://www.atheme.org) |
11 | */ |
11 | */ |
12 | |
12 | |
13 | static char const rcsid[] = "$Id: node.C,v 1.6 2007/09/16 18:54:45 pippijn Exp $"; |
13 | static char const rcsid[] = "$Id: node.C,v 1.7 2007/09/22 14:27:30 pippijn Exp $"; |
|
|
14 | |
|
|
15 | #include <boost/foreach.hpp> |
14 | |
16 | |
15 | #include "atheme.h" |
17 | #include "atheme.h" |
|
|
18 | #include <util/time.h> |
|
|
19 | #include <util/time.h> |
|
|
20 | #include <libermyth.h> |
16 | #include "servers.h" |
21 | #include "servers.h" |
17 | #include <account/kline.h> |
22 | #include <account/kline.h> |
18 | #include "uplink.h" |
23 | #include "uplink.h" |
19 | #include "privs.h" |
24 | #include "privs.h" |
20 | |
25 | |
… | |
… | |
41 | |
46 | |
42 | /* Mark everything illegal, to be called before a rehash -- jilles */ |
47 | /* Mark everything illegal, to be called before a rehash -- jilles */ |
43 | void |
48 | void |
44 | mark_all_illegal () |
49 | mark_all_illegal () |
45 | { |
50 | { |
46 | node_t *n, *tn; |
51 | std::vector<soper_t *> soper_mortals; |
47 | uplink_t *u; |
|
|
48 | soper_t *soper; |
|
|
49 | operclass_t *operclass; |
|
|
50 | |
52 | |
51 | LIST_FOREACH (n, uplinks.head) |
53 | foreach (uplink_t *u, uplinks) |
52 | { |
|
|
53 | u = (uplink_t *) n->data; |
|
|
54 | u->flags |= UPF_ILLEGAL; |
54 | u->flags |= UPF_ILLEGAL; |
55 | } |
|
|
56 | |
55 | |
57 | /* just delete these, we can survive without for a while */ |
56 | /* just delete these, we can survive without for a while */ |
58 | LIST_FOREACH_SAFE (n, tn, soperlist.head) |
57 | foreach (soper_t *soper, soper_t::list) |
59 | { |
|
|
60 | soper = (soper_t *) n->data; |
|
|
61 | if (soper->flags & SOPER_CONF) |
58 | if (soper->flags & SOPER_CONF) |
|
|
59 | soper_mortals.push_back (soper); |
|
|
60 | |
|
|
61 | while (!soper_mortals.empty ()) |
|
|
62 | { |
62 | soper_delete (soper); |
63 | soper_delete (soper_mortals.back ()); |
|
|
64 | soper_mortals.pop_back (); |
63 | } |
65 | } |
|
|
66 | |
64 | /* no sopers pointing to these anymore */ |
67 | /* no sopers pointing to these anymore */ |
65 | LIST_FOREACH_SAFE (n, tn, operclasslist.head) |
68 | while (!operclass_t::list.empty ()) |
66 | { |
|
|
67 | operclass = (operclass_t *) n->data; |
|
|
68 | operclass_delete (operclass); |
69 | operclass_delete (operclass_t::list.back ()); |
69 | } |
|
|
70 | } |
70 | } |
71 | |
71 | |
72 | /* Unmark everything illegal, to be called after a failed rehash -- jilles */ |
72 | /* Unmark everything illegal, to be called after a failed rehash -- jilles */ |
73 | void |
73 | void |
74 | unmark_all_illegal () |
74 | unmark_all_illegal () |
75 | { |
75 | { |
76 | node_t *n; |
76 | foreach (uplink_t *u, uplinks) |
77 | uplink_t *u; |
|
|
78 | |
|
|
79 | LIST_FOREACH (n, uplinks.head) |
|
|
80 | { |
|
|
81 | u = (uplink_t *) n->data; |
|
|
82 | u->flags &= ~UPF_ILLEGAL; |
77 | u->flags &= ~UPF_ILLEGAL; |
83 | } |
|
|
84 | } |
78 | } |
85 | |
79 | |
86 | /* Remove illegal stuff, to be called after a successful rehash -- jilles */ |
80 | /* Remove illegal stuff, to be called after a successful rehash -- jilles */ |
87 | void |
81 | void |
88 | remove_illegals () |
82 | remove_illegals () |
89 | { |
83 | { |
90 | node_t *n, *tn; |
84 | std::vector<uplink_t *> mortals; |
91 | uplink_t *u; |
|
|
92 | |
85 | |
93 | LIST_FOREACH_SAFE (n, tn, uplinks.head) |
86 | foreach (uplink_t *u, uplinks) |
94 | { |
87 | { |
95 | u = (uplink_t *) n->data; |
|
|
96 | if (u->flags & UPF_ILLEGAL && u != curr_uplink) |
88 | if (u->flags & UPF_ILLEGAL && u != curr_uplink) |
97 | uplink_delete (u); |
89 | mortals.push_back (u); |
98 | } |
90 | } |
|
|
91 | |
|
|
92 | while (!mortals.empty ()) |
|
|
93 | { |
|
|
94 | uplink_delete (mortals.back ()); |
|
|
95 | mortals.pop_back (); |
|
|
96 | } |
99 | } |
97 | } |
100 | |
98 | |
101 | /************* |
99 | /************* |
102 | * K L I N E * |
100 | * K L I N E * |
103 | *************/ |
101 | *************/ |