Blame SOURCES/patch.4.7.25.4

69b435
*** cvotn/dbinc/repmgr.h.orig	2009-05-04 10:33:55.000000000 -0400
69b435
--- cvotn/dbinc/repmgr.h	2009-05-04 10:27:26.000000000 -0400
69b435
***************
69b435
*** 374,379 ****
69b435
--- 374,380 ----
69b435
  #define	SITE_FROM_EID(eid)	(&db_rep->sites[eid])
69b435
  #define	EID_FROM_SITE(s)	((int)((s) - (&db_rep->sites[0])))
69b435
  #define	IS_VALID_EID(e)		((e) >= 0)
69b435
+ #define	IS_KNOWN_REMOTE_SITE(e)	((e) >= 0 && ((u_int)(e)) < db_rep->site_cnt)
69b435
  #define	SELF_EID		INT_MAX
69b435
  
69b435
  #define	IS_PEER_POLICY(p) ((p) == DB_REPMGR_ACKS_ALL_PEERS ||		\
69b435
*** cvotn/rep/rep_elect.c.orig	2009-05-04 10:35:50.000000000 -0400
69b435
--- cvotn/rep/rep_elect.c	2009-05-04 10:31:24.000000000 -0400
69b435
***************
69b435
*** 33,39 ****
69b435
  static int __rep_fire_elected __P((ENV *, REP *, u_int32_t));
69b435
  static void __rep_elect_master __P((ENV *, REP *));
69b435
  static int __rep_tally __P((ENV *, REP *, int, u_int32_t *, u_int32_t, roff_t));
69b435
! static int __rep_wait __P((ENV *, db_timeout_t *, int *, int, u_int32_t));
69b435
  
69b435
  /*
69b435
   * __rep_elect --
69b435
--- 33,39 ----
69b435
  static int __rep_fire_elected __P((ENV *, REP *, u_int32_t));
69b435
  static void __rep_elect_master __P((ENV *, REP *));
69b435
  static int __rep_tally __P((ENV *, REP *, int, u_int32_t *, u_int32_t, roff_t));
69b435
! static int __rep_wait __P((ENV *, db_timeout_t *, int, u_int32_t));
69b435
  
69b435
  /*
69b435
   * __rep_elect --
69b435
***************
69b435
*** 55,61 ****
69b435
  	ENV *env;
69b435
  	LOG *lp;
69b435
  	REP *rep;
69b435
! 	int done, eid, elected, full_elect, locked, in_progress, need_req;
69b435
  	int ret, send_vote, t_ret;
69b435
  	u_int32_t ack, ctlflags, egen, nsites, orig_tally, priority, realpri;
69b435
  	u_int32_t tiebreaker;
69b435
--- 55,61 ----
69b435
  	ENV *env;
69b435
  	LOG *lp;
69b435
  	REP *rep;
69b435
! 	int done, elected, full_elect, locked, in_progress, need_req;
69b435
  	int ret, send_vote, t_ret;
69b435
  	u_int32_t ack, ctlflags, egen, nsites, orig_tally, priority, realpri;
69b435
  	u_int32_t tiebreaker;
69b435
***************
69b435
*** 181,188 ****
69b435
  			REP_SYSTEM_UNLOCK(env);
69b435
  			(void)__rep_send_message(env, DB_EID_BROADCAST,
69b435
  			    REP_MASTER_REQ, NULL, NULL, 0, 0);
69b435
! 			ret = __rep_wait(env, &to, &eid,
69b435
! 			    0, REP_F_EPHASE0);
69b435
  			REP_SYSTEM_LOCK(env);
69b435
  			F_CLR(rep, REP_F_EPHASE0);
69b435
  			switch (ret) {
69b435
--- 181,187 ----
69b435
  			REP_SYSTEM_UNLOCK(env);
69b435
  			(void)__rep_send_message(env, DB_EID_BROADCAST,
69b435
  			    REP_MASTER_REQ, NULL, NULL, 0, 0);
69b435
! 			ret = __rep_wait(env, &to, 0, REP_F_EPHASE0);
69b435
  			REP_SYSTEM_LOCK(env);
69b435
  			F_CLR(rep, REP_F_EPHASE0);
69b435
  			switch (ret) {
69b435
***************
69b435
*** 286,296 ****
69b435
  		REP_SYSTEM_LOCK(env);
69b435
  		goto vote;
69b435
  	}
69b435
! 	ret = __rep_wait(env, &to, &eid, full_elect, REP_F_EPHASE1);
69b435
  	switch (ret) {
69b435
  		case 0:
69b435
  			/* Check if election complete or phase complete. */
69b435
! 			if (eid != DB_EID_INVALID && !IN_ELECTION(rep)) {
69b435
  				RPRINT(env, DB_VERB_REP_ELECT,
69b435
  				    (env, "Ended election phase 1"));
69b435
  				goto edone;
69b435
--- 285,295 ----
69b435
  		REP_SYSTEM_LOCK(env);
69b435
  		goto vote;
69b435
  	}
69b435
! 	ret = __rep_wait(env, &to, full_elect, REP_F_EPHASE1);
69b435
  	switch (ret) {
69b435
  		case 0:
69b435
  			/* Check if election complete or phase complete. */
69b435
! 			if (!IN_ELECTION(rep)) {
69b435
  				RPRINT(env, DB_VERB_REP_ELECT,
69b435
  				    (env, "Ended election phase 1"));
69b435
  				goto edone;
69b435
***************
69b435
*** 398,412 ****
69b435
  		REP_SYSTEM_LOCK(env);
69b435
  		goto i_won;
69b435
  	}
69b435
! 	ret = __rep_wait(env, &to, &eid, full_elect, REP_F_EPHASE2);
69b435
  	RPRINT(env, DB_VERB_REP_ELECT,
69b435
  	    (env, "Ended election phase 2 %d", ret));
69b435
  	switch (ret) {
69b435
  		case 0:
69b435
! 			if (eid != DB_EID_INVALID)
69b435
! 				goto edone;
69b435
! 			ret = DB_REP_UNAVAIL;
69b435
! 			break;
69b435
  		case DB_REP_EGENCHG:
69b435
  			if (to > timeout)
69b435
  				to = timeout;
69b435
--- 397,408 ----
69b435
  		REP_SYSTEM_LOCK(env);
69b435
  		goto i_won;
69b435
  	}
69b435
! 	ret = __rep_wait(env, &to, full_elect, REP_F_EPHASE2);
69b435
  	RPRINT(env, DB_VERB_REP_ELECT,
69b435
  	    (env, "Ended election phase 2 %d", ret));
69b435
  	switch (ret) {
69b435
  		case 0:
69b435
! 			goto edone;
69b435
  		case DB_REP_EGENCHG:
69b435
  			if (to > timeout)
69b435
  				to = timeout;
69b435
***************
69b435
*** 1050,1062 ****
69b435
  	ENV *env;
69b435
  	REP *rep;
69b435
  {
69b435
- 	/*
69b435
- 	 * We often come through here twice, sometimes even more.  We mustn't
69b435
- 	 * let the redundant calls affect stats counting.  But rep_elect relies
69b435
- 	 * on this first part for setting eidp.
69b435
- 	 */
69b435
- 	rep->master_id = rep->eid;
69b435
- 
69b435
  	if (F_ISSET(rep, REP_F_MASTERELECT | REP_F_MASTER)) {
69b435
  		/* We've been through here already; avoid double counting. */
69b435
  		return;
69b435
--- 1046,1051 ----
69b435
***************
69b435
*** 1093,1102 ****
69b435
  	(timeout > 5000000) ? 500000 : ((timeout >= 10) ? timeout / 10 : 1);
69b435
  
69b435
  static int
69b435
! __rep_wait(env, timeoutp, eidp, full_elect, flags)
69b435
  	ENV *env;
69b435
  	db_timeout_t *timeoutp;
69b435
! 	int *eidp, full_elect;
69b435
  	u_int32_t flags;
69b435
  {
69b435
  	DB_REP *db_rep;
69b435
--- 1082,1091 ----
69b435
  	(timeout > 5000000) ? 500000 : ((timeout >= 10) ? timeout / 10 : 1);
69b435
  
69b435
  static int
69b435
! __rep_wait(env, timeoutp, full_elect, flags)
69b435
  	ENV *env;
69b435
  	db_timeout_t *timeoutp;
69b435
! 	int full_elect;
69b435
  	u_int32_t flags;
69b435
  {
69b435
  	DB_REP *db_rep;
69b435
***************
69b435
*** 1174,1180 ****
69b435
  			F_CLR(rep, REP_F_EGENUPDATE);
69b435
  			ret = DB_REP_EGENCHG;
69b435
  		} else if (phase_over) {
69b435
- 			*eidp = rep->master_id;
69b435
  			done = 1;
69b435
  			ret = 0;
69b435
  		}
69b435
--- 1163,1168 ----
69b435
*** cvotn/repmgr/repmgr_net.c.orig	2009-05-04 10:34:46.000000000 -0400
69b435
--- cvotn/repmgr/repmgr_net.c	2009-05-04 10:27:26.000000000 -0400
69b435
***************
69b435
*** 100,105 ****
69b435
--- 100,107 ----
69b435
  		    control, rec, &nsites_sent, &npeers_sent)) != 0)
69b435
  			goto out;
69b435
  	} else {
69b435
+ 		DB_ASSERT(env, IS_KNOWN_REMOTE_SITE(eid));
69b435
+ 
69b435
  		/*
69b435
  		 * If this is a request that can be sent anywhere, then see if
69b435
  		 * we can send it to our peer (to save load on the master), but