]>
Commit | Line | Data |
---|---|---|
1825d9ec ER |
1 | *** dbinc/repmgr.h 2009-05-04 10:33:55.000000000 -0400 |
2 | --- dbinc/repmgr.h 2009-05-04 10:27:26.000000000 -0400 | |
2dee7534 ER |
3 | *************** |
4 | *** 374,379 **** | |
5 | --- 374,380 ---- | |
6 | #define SITE_FROM_EID(eid) (&db_rep->sites[eid]) | |
7 | #define EID_FROM_SITE(s) ((int)((s) - (&db_rep->sites[0]))) | |
8 | #define IS_VALID_EID(e) ((e) >= 0) | |
9 | + #define IS_KNOWN_REMOTE_SITE(e) ((e) >= 0 && ((u_int)(e)) < db_rep->site_cnt) | |
10 | #define SELF_EID INT_MAX | |
11 | ||
12 | #define IS_PEER_POLICY(p) ((p) == DB_REPMGR_ACKS_ALL_PEERS || \ | |
1825d9ec ER |
13 | *** rep/rep_elect.c 2009-05-04 10:35:50.000000000 -0400 |
14 | --- rep/rep_elect.c 2009-05-04 10:31:24.000000000 -0400 | |
2dee7534 ER |
15 | *************** |
16 | *** 33,39 **** | |
17 | static int __rep_fire_elected __P((ENV *, REP *, u_int32_t)); | |
18 | static void __rep_elect_master __P((ENV *, REP *)); | |
19 | static int __rep_tally __P((ENV *, REP *, int, u_int32_t *, u_int32_t, roff_t)); | |
20 | ! static int __rep_wait __P((ENV *, db_timeout_t *, int *, int, u_int32_t)); | |
21 | ||
22 | /* | |
23 | * __rep_elect -- | |
24 | --- 33,39 ---- | |
25 | static int __rep_fire_elected __P((ENV *, REP *, u_int32_t)); | |
26 | static void __rep_elect_master __P((ENV *, REP *)); | |
27 | static int __rep_tally __P((ENV *, REP *, int, u_int32_t *, u_int32_t, roff_t)); | |
28 | ! static int __rep_wait __P((ENV *, db_timeout_t *, int, u_int32_t)); | |
29 | ||
30 | /* | |
31 | * __rep_elect -- | |
32 | *************** | |
33 | *** 55,61 **** | |
34 | ENV *env; | |
35 | LOG *lp; | |
36 | REP *rep; | |
37 | ! int done, eid, elected, full_elect, locked, in_progress, need_req; | |
38 | int ret, send_vote, t_ret; | |
39 | u_int32_t ack, ctlflags, egen, nsites, orig_tally, priority, realpri; | |
40 | u_int32_t tiebreaker; | |
41 | --- 55,61 ---- | |
42 | ENV *env; | |
43 | LOG *lp; | |
44 | REP *rep; | |
45 | ! int done, elected, full_elect, locked, in_progress, need_req; | |
46 | int ret, send_vote, t_ret; | |
47 | u_int32_t ack, ctlflags, egen, nsites, orig_tally, priority, realpri; | |
48 | u_int32_t tiebreaker; | |
49 | *************** | |
50 | *** 181,188 **** | |
51 | REP_SYSTEM_UNLOCK(env); | |
52 | (void)__rep_send_message(env, DB_EID_BROADCAST, | |
53 | REP_MASTER_REQ, NULL, NULL, 0, 0); | |
54 | ! ret = __rep_wait(env, &to, &eid, | |
55 | ! 0, REP_F_EPHASE0); | |
56 | REP_SYSTEM_LOCK(env); | |
57 | F_CLR(rep, REP_F_EPHASE0); | |
58 | switch (ret) { | |
59 | --- 181,187 ---- | |
60 | REP_SYSTEM_UNLOCK(env); | |
61 | (void)__rep_send_message(env, DB_EID_BROADCAST, | |
62 | REP_MASTER_REQ, NULL, NULL, 0, 0); | |
63 | ! ret = __rep_wait(env, &to, 0, REP_F_EPHASE0); | |
64 | REP_SYSTEM_LOCK(env); | |
65 | F_CLR(rep, REP_F_EPHASE0); | |
66 | switch (ret) { | |
67 | *************** | |
68 | *** 286,296 **** | |
69 | REP_SYSTEM_LOCK(env); | |
70 | goto vote; | |
71 | } | |
72 | ! ret = __rep_wait(env, &to, &eid, full_elect, REP_F_EPHASE1); | |
73 | switch (ret) { | |
74 | case 0: | |
75 | /* Check if election complete or phase complete. */ | |
76 | ! if (eid != DB_EID_INVALID && !IN_ELECTION(rep)) { | |
77 | RPRINT(env, DB_VERB_REP_ELECT, | |
78 | (env, "Ended election phase 1")); | |
79 | goto edone; | |
80 | --- 285,295 ---- | |
81 | REP_SYSTEM_LOCK(env); | |
82 | goto vote; | |
83 | } | |
84 | ! ret = __rep_wait(env, &to, full_elect, REP_F_EPHASE1); | |
85 | switch (ret) { | |
86 | case 0: | |
87 | /* Check if election complete or phase complete. */ | |
88 | ! if (!IN_ELECTION(rep)) { | |
89 | RPRINT(env, DB_VERB_REP_ELECT, | |
90 | (env, "Ended election phase 1")); | |
91 | goto edone; | |
92 | *************** | |
93 | *** 398,412 **** | |
94 | REP_SYSTEM_LOCK(env); | |
95 | goto i_won; | |
96 | } | |
97 | ! ret = __rep_wait(env, &to, &eid, full_elect, REP_F_EPHASE2); | |
98 | RPRINT(env, DB_VERB_REP_ELECT, | |
99 | (env, "Ended election phase 2 %d", ret)); | |
100 | switch (ret) { | |
101 | case 0: | |
102 | ! if (eid != DB_EID_INVALID) | |
103 | ! goto edone; | |
104 | ! ret = DB_REP_UNAVAIL; | |
105 | ! break; | |
106 | case DB_REP_EGENCHG: | |
107 | if (to > timeout) | |
108 | to = timeout; | |
109 | --- 397,408 ---- | |
110 | REP_SYSTEM_LOCK(env); | |
111 | goto i_won; | |
112 | } | |
113 | ! ret = __rep_wait(env, &to, full_elect, REP_F_EPHASE2); | |
114 | RPRINT(env, DB_VERB_REP_ELECT, | |
115 | (env, "Ended election phase 2 %d", ret)); | |
116 | switch (ret) { | |
117 | case 0: | |
118 | ! goto edone; | |
119 | case DB_REP_EGENCHG: | |
120 | if (to > timeout) | |
121 | to = timeout; | |
122 | *************** | |
123 | *** 1050,1062 **** | |
124 | ENV *env; | |
125 | REP *rep; | |
126 | { | |
127 | - /* | |
128 | - * We often come through here twice, sometimes even more. We mustn't | |
129 | - * let the redundant calls affect stats counting. But rep_elect relies | |
130 | - * on this first part for setting eidp. | |
131 | - */ | |
132 | - rep->master_id = rep->eid; | |
133 | - | |
134 | if (F_ISSET(rep, REP_F_MASTERELECT | REP_F_MASTER)) { | |
135 | /* We've been through here already; avoid double counting. */ | |
136 | return; | |
137 | --- 1046,1051 ---- | |
138 | *************** | |
139 | *** 1093,1102 **** | |
140 | (timeout > 5000000) ? 500000 : ((timeout >= 10) ? timeout / 10 : 1); | |
141 | ||
142 | static int | |
143 | ! __rep_wait(env, timeoutp, eidp, full_elect, flags) | |
144 | ENV *env; | |
145 | db_timeout_t *timeoutp; | |
146 | ! int *eidp, full_elect; | |
147 | u_int32_t flags; | |
148 | { | |
149 | DB_REP *db_rep; | |
150 | --- 1082,1091 ---- | |
151 | (timeout > 5000000) ? 500000 : ((timeout >= 10) ? timeout / 10 : 1); | |
152 | ||
153 | static int | |
154 | ! __rep_wait(env, timeoutp, full_elect, flags) | |
155 | ENV *env; | |
156 | db_timeout_t *timeoutp; | |
157 | ! int full_elect; | |
158 | u_int32_t flags; | |
159 | { | |
160 | DB_REP *db_rep; | |
161 | *************** | |
162 | *** 1174,1180 **** | |
163 | F_CLR(rep, REP_F_EGENUPDATE); | |
164 | ret = DB_REP_EGENCHG; | |
165 | } else if (phase_over) { | |
166 | - *eidp = rep->master_id; | |
167 | done = 1; | |
168 | ret = 0; | |
169 | } | |
170 | --- 1163,1168 ---- | |
1825d9ec ER |
171 | *** repmgr/repmgr_net.c 2009-05-04 10:34:46.000000000 -0400 |
172 | --- repmgr/repmgr_net.c 2009-05-04 10:27:26.000000000 -0400 | |
2dee7534 ER |
173 | *************** |
174 | *** 100,105 **** | |
175 | --- 100,107 ---- | |
176 | control, rec, &nsites_sent, &npeers_sent)) != 0) | |
177 | goto out; | |
178 | } else { | |
179 | + DB_ASSERT(env, IS_KNOWN_REMOTE_SITE(eid)); | |
180 | + | |
181 | /* | |
182 | * If this is a request that can be sent anywhere, then see if | |
183 | * we can send it to our peer (to save load on the master), but |