1 *** dbinc/repmgr.h 2009-05-04 10:33:55.000000000 -0400
2 --- dbinc/repmgr.h 2009-05-04 10:27:26.000000000 -0400
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
12 #define IS_PEER_POLICY(p) ((p) == DB_REPMGR_ACKS_ALL_PEERS || \
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
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));
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));
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;
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;
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,
57 F_CLR(rep, REP_F_EPHASE0);
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);
65 F_CLR(rep, REP_F_EPHASE0);
72 ! ret = __rep_wait(env, &to, &eid, full_elect, REP_F_EPHASE1);
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"));
84 ! ret = __rep_wait(env, &to, full_elect, REP_F_EPHASE1);
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"));
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));
102 ! if (eid != DB_EID_INVALID)
104 ! ret = DB_REP_UNAVAIL;
110 REP_SYSTEM_LOCK(env);
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));
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.
132 - rep->master_id = rep->eid;
134 if (F_ISSET(rep, REP_F_MASTERELECT | REP_F_MASTER)) {
135 /* We've been through here already; avoid double counting. */
140 (timeout > 5000000) ? 500000 : ((timeout >= 10) ? timeout / 10 : 1);
143 ! __rep_wait(env, timeoutp, eidp, full_elect, flags)
145 db_timeout_t *timeoutp;
146 ! int *eidp, full_elect;
151 (timeout > 5000000) ? 500000 : ((timeout >= 10) ? timeout / 10 : 1);
154 ! __rep_wait(env, timeoutp, full_elect, flags)
156 db_timeout_t *timeoutp;
163 F_CLR(rep, REP_F_EGENUPDATE);
164 ret = DB_REP_EGENCHG;
165 } else if (phase_over) {
166 - *eidp = rep->master_id;
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
176 control, rec, &nsites_sent, &npeers_sent)) != 0)
179 + DB_ASSERT(env, IS_KNOWN_REMOTE_SITE(eid));
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