@@ -71,7 +71,7 @@ struct Election {
7171 void queue_timeout_message (int from, int to, function<void ()> m);
7272 void queue_stable_or_timeout (int from, int to,
7373 function<void ()> m, function<void()> t);
74- void queue_election_message (int from, int to, function<void ()> m);
74+ void queue_election_message (int from, int to, function<void (bool )> m);
7575
7676 // test runner interfaces
7777 int run_timesteps (int max);
@@ -317,21 +317,24 @@ void Election::queue_stable_message(int from, int to, function<void()> m)
317317 }
318318}
319319
320- void Election::queue_election_message (int from, int to, function<void ()> m)
320+ void Election::queue_election_message (int from, int to, function<void (bool )> m)
321321{
322322 if (last_quorum_reported.count (from)) {
323323 last_quorum_change = timesteps_run;
324324 last_quorum_reported.clear ();
325325 last_leader = -1 ;
326326 }
327- if (!blocked_messages[from].count (to)) {
327+ const bool blocked = blocked_messages[from].count (to);
328+ if (blocked) {
329+ return m (true );
330+ } else {
328331 bufferlist bl;
329332 electors[from]->encode_scores (bl);
330333 Owner *o = electors[to];
331334 messages.push_back ([this ,m,o,bl] {
332335 --this ->pending_election_messages ;
333336 o->receive_scores (bl);
334- m ();
337+ m (false );
335338 });
336339 ++pending_election_messages;
337340 }
@@ -356,37 +359,47 @@ void Election::queue_stable_or_timeout(int from, int to,
356359void Election::defer_to (int from, int to, epoch_t e)
357360{
358361 Owner *o = electors[to];
359- queue_election_message (from, to, [o, from, e] {
360- o->receive_ack (from, e);
361- });
362+ queue_election_message (from, to, [o, from, e](bool blocked) {
363+ if (!blocked) {
364+ o->receive_ack (from, e);
365+ }
366+ });
362367}
363368
364369void Election::propose_to (int from, int to, epoch_t e, bufferlist& cbl)
365370{
366371 Owner *o = electors[to];
367372 ConnectionTracker *oct = NULL ;
368373 if (cbl.length ()) {
369- oct = new ConnectionTracker (cbl, g_ceph_context); // we leak these on blocked cons, meh
374+ oct = new ConnectionTracker (cbl, g_ceph_context);
370375 }
371- queue_election_message (from, to, [o, from, e, oct] {
372- o->receive_propose (from, e, oct);
376+ queue_election_message (from, to, [o, from, e, oct](bool blocked) {
377+ if (blocked) {
378+ delete oct;
379+ } else {
380+ o->receive_propose (from, e, oct);
381+ }
373382 });
374383}
375384
376385void Election::claim_victory (int from, int to, epoch_t e, const set<int >& members)
377386{
378387 Owner *o = electors[to];
379- queue_election_message (from, to, [o, from, e, members] {
388+ queue_election_message (from, to, [o, from, e, members](bool blocked) {
389+ if (!blocked) {
380390 o->receive_victory_claim (from, e, members);
381- });
391+ }
392+ });
382393}
383394
384395void Election::accept_victory (int from, int to, epoch_t e)
385396{
386397 Owner *o = electors[to];
387- queue_election_message (from, to, [o, from, e] {
398+ queue_election_message (from, to, [o, from, e](bool blocked) {
399+ if (!blocked) {
388400 o->receive_victory_ack (from, e);
389- });
401+ }
402+ });
390403}
391404
392405void Election::report_quorum (const set<int >& quorum)
0 commit comments