uint64_t ProtocolV1::discard_requeued_up_to(uint64_t out_seq, uint64_t seq) {
ldout(cct, 10) << __func__ << " " << seq << dendl;
std::lock_guard<std::mutex> l(connection->write_lock);
- if (out_q.count(CEPH_MSG_PRIO_HIGHEST) == 0) {
+ const auto it = out_q.find(CEPH_MSG_PRIO_HIGHEST);
+ if (it == out_q.end()) {
return seq;
}
- auto &rq = out_q[CEPH_MSG_PRIO_HIGHEST];
+ auto &rq = it->second;
uint64_t count = out_seq;
while (!rq.empty()) {
Message* const m = rq.front().m;
rq.pop_front();
count++;
}
- if (rq.empty()) out_q.erase(CEPH_MSG_PRIO_HIGHEST);
+ if (rq.empty()) out_q.erase(it);
return count;
}
ProtocolV1::out_q_entry_t ProtocolV1::_get_next_outgoing() {
out_q_entry_t out_entry;
- if (!out_q.empty()) {
- const auto it = out_q.begin();
+ if (const auto it = out_q.begin(); it != out_q.end()) {
ceph_assert(!it->second.empty());
const auto p = it->second.begin();
out_entry = *p;
uint64_t ProtocolV2::discard_requeued_up_to(uint64_t out_seq, uint64_t seq) {
ldout(cct, 10) << __func__ << " " << seq << dendl;
std::lock_guard<std::mutex> l(connection->write_lock);
- if (out_queue.count(CEPH_MSG_PRIO_HIGHEST) == 0) {
+ const auto it = out_queue.find(CEPH_MSG_PRIO_HIGHEST);
+ if (it == out_queue.end()) {
return seq;
}
- auto& rq = out_queue[CEPH_MSG_PRIO_HIGHEST];
+ auto& rq = it->second;
uint64_t count = out_seq;
while (!rq.empty()) {
Message* const m = rq.front().m;
rq.pop_front();
count++;
}
- if (rq.empty()) out_queue.erase(CEPH_MSG_PRIO_HIGHEST);
+ if (rq.empty()) out_queue.erase(it);
return count;
}
ProtocolV2::out_queue_entry_t ProtocolV2::_get_next_outgoing() {
out_queue_entry_t out_entry;
- if (!out_queue.empty()) {
- auto it = out_queue.begin();
+ if (const auto it = out_queue.begin(); it != out_queue.end()) {
auto& entries = it->second;
ceph_assert(!entries.empty());
out_entry = entries.front();