void MonClient::_send_command(MonCommand *r)
{
+ ++r->send_attempts;
+
entity_addr_t peer;
if (active_con) {
peer = active_con->get_con()->get_peer_addr();
if (r->target_rank >= 0 &&
r->target_rank != monmap.get_rank(peer)) {
+ if (r->send_attempts > 1) {
+ _finish_command(r, -ENXIO, "mon unavailable");
+ return;
+ }
ldout(cct, 10) << __func__ << " " << r->tid << " " << r->cmd
<< " wants rank " << r->target_rank
<< ", reopening session"
if (r->target_name.length() &&
r->target_name != monmap.get_name(peer)) {
+ if (r->send_attempts > 1) {
+ _finish_command(r, -ENXIO, "mon unavailable");
+ return;
+ }
ldout(cct, 10) << __func__ << " " << r->tid << " " << r->cmd
<< " wants mon " << r->target_name
<< ", reopening session"
void MonClient::_resend_mon_commands()
{
// resend any requests
- for (map<uint64_t,MonCommand*>::iterator p = mon_commands.begin();
- p != mon_commands.end();
- ++p) {
- _send_command(p->second);
+ map<uint64_t,MonCommand*>::iterator p = mon_commands.begin();
+ while (p != mon_commands.end()) {
+ auto cmd = p->second;
+ ++p;
+ _send_command(cmd); // might remove cmd from mon_commands
}
}