3 @@ -374,6 +374,7 @@ typedef struct {
4 #define SITE_FROM_EID(eid) (&db_rep->sites[eid])
5 #define EID_FROM_SITE(s) ((int)((s) - (&db_rep->sites[0])))
6 #define IS_VALID_EID(e) ((e) >= 0)
7 +#define IS_KNOWN_REMOTE_SITE(e) ((e) >= 0 && ((u_int)(e)) < db_rep->site_cnt)
8 #define SELF_EID INT_MAX
10 #define IS_PEER_POLICY(p) ((p) == DB_REPMGR_ACKS_ALL_PEERS || \
13 @@ -33,7 +33,7 @@ static int __rep_elect_init
14 static int __rep_fire_elected __P((ENV *, REP *, u_int32_t));
15 static void __rep_elect_master __P((ENV *, REP *));
16 static int __rep_tally __P((ENV *, REP *, int, u_int32_t *, u_int32_t, roff_t));
17 -static int __rep_wait __P((ENV *, db_timeout_t *, int *, int, u_int32_t));
18 +static int __rep_wait __P((ENV *, db_timeout_t *, int, u_int32_t));
22 @@ -55,7 +55,7 @@ __rep_elect(dbenv, given_nsites, nvotes,
26 - int done, eid, elected, full_elect, locked, in_progress, need_req;
27 + int done, elected, full_elect, locked, in_progress, need_req;
28 int ret, send_vote, t_ret;
29 u_int32_t ack, ctlflags, egen, nsites, orig_tally, priority, realpri;
31 @@ -181,8 +181,7 @@ __rep_elect(dbenv, given_nsites, nvotes,
32 REP_SYSTEM_UNLOCK(env);
33 (void)__rep_send_message(env, DB_EID_BROADCAST,
34 REP_MASTER_REQ, NULL, NULL, 0, 0);
35 - ret = __rep_wait(env, &to, &eid,
37 + ret = __rep_wait(env, &to, 0, REP_F_EPHASE0);
39 F_CLR(rep, REP_F_EPHASE0);
41 @@ -286,11 +285,11 @@ restart:
45 - ret = __rep_wait(env, &to, &eid, full_elect, REP_F_EPHASE1);
46 + ret = __rep_wait(env, &to, full_elect, REP_F_EPHASE1);
49 /* Check if election complete or phase complete. */
50 - if (eid != DB_EID_INVALID && !IN_ELECTION(rep)) {
51 + if (!IN_ELECTION(rep)) {
52 RPRINT(env, DB_VERB_REP_ELECT,
53 (env, "Ended election phase 1"));
55 @@ -398,15 +397,12 @@ phase2:
59 - ret = __rep_wait(env, &to, &eid, full_elect, REP_F_EPHASE2);
60 + ret = __rep_wait(env, &to, full_elect, REP_F_EPHASE2);
61 RPRINT(env, DB_VERB_REP_ELECT,
62 (env, "Ended election phase 2 %d", ret));
65 - if (eid != DB_EID_INVALID)
67 - ret = DB_REP_UNAVAIL;
73 @@ -1050,13 +1046,6 @@ __rep_elect_master(env, rep)
78 - * We often come through here twice, sometimes even more. We mustn't
79 - * let the redundant calls affect stats counting. But rep_elect relies
80 - * on this first part for setting eidp.
82 - rep->master_id = rep->eid;
84 if (F_ISSET(rep, REP_F_MASTERELECT | REP_F_MASTER)) {
85 /* We've been through here already; avoid double counting. */
87 @@ -1093,10 +1082,10 @@ __rep_fire_elected(env, rep, egen)
88 (timeout > 5000000) ? 500000 : ((timeout >= 10) ? timeout / 10 : 1);
91 -__rep_wait(env, timeoutp, eidp, full_elect, flags)
92 +__rep_wait(env, timeoutp, full_elect, flags)
94 db_timeout_t *timeoutp;
95 - int *eidp, full_elect;
100 @@ -1174,7 +1163,6 @@ __rep_wait(env, timeoutp, eidp, full_ele
101 F_CLR(rep, REP_F_EGENUPDATE);
102 ret = DB_REP_EGENCHG;
103 } else if (phase_over) {
104 - *eidp = rep->master_id;
108 --- a/repmgr/repmgr_net.c
109 +++ b/repmgr/repmgr_net.c
110 @@ -100,6 +100,8 @@ __repmgr_send(dbenv, control, rec, lsnp,
111 control, rec, &nsites_sent, &npeers_sent)) != 0)
114 + DB_ASSERT(env, IS_KNOWN_REMOTE_SITE(eid));
117 * If this is a request that can be sent anywhere, then see if
118 * we can send it to our peer (to save load on the master), but