unsigned Consensus::yea(unsigned memberId) { /* throws VoteException */ SimpleMutex::scoped_lock lk(lyMutex); LastYea &L = this->ly.ref(lk); time_t now = time(0); if( L.when + LeaseTime >= now && L.who != memberId ) { LOG(1) << "replSet not voting yea for " << memberId << " voted for " << L.who << ' ' << now-L.when << " secs ago" << rsLog; throw VoteException(); } L.when = now; L.who = memberId; return rs._self->config().votes; }
unsigned Consensus::yea(unsigned memberId) { /* throws VoteException */ Atomic<LastYea>::tran t(ly); LastYea &ly = t.ref(); time_t now = time(0); if( ly.when + LeaseTime >= now && ly.who != memberId ) { log(1) << "replSet not voting yea for " << memberId << " voted for " << ly.who << ' ' << now-ly.when << " secs ago" << rsLog; throw VoteException(); } ly.when = now; ly.who = memberId; return rs._self->config().votes; }