diff options
author | Sage Weil <sage@inktank.com> | 2012-11-28 16:04:44 -0800 |
---|---|---|
committer | Sage Weil <sage@inktank.com> | 2012-11-29 12:38:51 -0800 |
commit | e16533029e659aeaae1b0cc32ea3fbc8da334b0c (patch) | |
tree | 93338365f858376303b2fa425beb891fe36a715b | |
parent | ea65dffff2d78f10894deac7f92d330d3cc37ccd (diff) | |
download | ceph-e16533029e659aeaae1b0cc32ea3fbc8da334b0c.tar.gz |
osd: use safe OSDService msgr helpers for heartbeats
Get connections via the OSDService helper.
Signed-off-by: Sage Weil <sage@inktank.com>
-rw-r--r-- | src/osd/OSD.cc | 15 | ||||
-rw-r--r-- | src/osd/OSD.h | 2 |
2 files changed, 13 insertions, 4 deletions
diff --git a/src/osd/OSD.cc b/src/osd/OSD.cc index 914d1dcc88a..eef6d15f7db 100644 --- a/src/osd/OSD.cc +++ b/src/osd/OSD.cc @@ -1780,9 +1780,12 @@ void OSD::_add_heartbeat_peer(int p) map<int,HeartbeatInfo>::iterator i = heartbeat_peers.find(p); if (i == heartbeat_peers.end()) { + Connection *con = service.get_con_osd_hb(p, osdmap->get_epoch()); + if (!con) + return; hi = &heartbeat_peers[p]; - hi->inst = osdmap->get_hb_inst(p); - hi->con = hbclient_messenger->get_connection(hi->inst); + hi->con = con; + hi->peer = p; hi->con->set_priv(new HeartbeatSession(p)); dout(10) << "_add_heartbeat_peer: new peer osd." << p << " " << hi->con->get_peer_addr() << dendl; @@ -2073,8 +2076,14 @@ bool OSD::heartbeat_reset(Connection *con) map<int,HeartbeatInfo>::iterator p = heartbeat_peers.find(s->peer); if (p != heartbeat_peers.end() && p->second.con == con) { + Connection *newcon = service.get_con_osd_hb(p->second.peer, p->second.epoch); + if (!newcon) { + dout(10) << "heartbeat_reset reopen failed hb con " << con << " but failed to reopen" << dendl; + s->put(); + return true; + } dout(10) << "heartbeat_reset reopen failed hb con " << con << dendl; - p->second.con = hbclient_messenger->get_connection(p->second.inst); + p->second.con = newcon; p->second.con->set_priv(s); } else { dout(10) << "heartbeat_reset closing (old) failed hb con " << con << dendl; diff --git a/src/osd/OSD.h b/src/osd/OSD.h index 4608891a20d..d9e8de247da 100644 --- a/src/osd/OSD.h +++ b/src/osd/OSD.h @@ -478,7 +478,7 @@ private: // -- heartbeat -- /// information about a heartbeat peer struct HeartbeatInfo { - entity_inst_t inst; ///< peer + int peer; ///< peer Connection *con; ///< peer connection utime_t first_tx; ///< time we sent our first ping request utime_t last_tx; ///< last time we sent a ping request |