]> git.apps.os.sepia.ceph.com Git - ceph-ci.git/commitdiff
osd/OSD.cc: remove repeated searching of map
authorMichal Jarzabek <stiopa@gmail.com>
Mon, 5 Sep 2016 21:56:43 +0000 (22:56 +0100)
committerMichal Jarzabek <stiopa@gmail.com>
Mon, 5 Sep 2016 21:57:58 +0000 (22:57 +0100)
Signed-off-by: Michal Jarzabek <stiopa@gmail.com>
src/osd/OSD.cc

index 3dc490fea8b28200a963f3b043314ac2cd8c64aa..c1f3a54d0d0d02cdc3adba343b721e34453416d5 100644 (file)
@@ -3988,22 +3988,24 @@ void OSD::handle_osd_ping(MOSDPing *m)
   case MOSDPing::PING:
     {
       if (cct->_conf->osd_debug_drop_ping_probability > 0) {
-       if (debug_heartbeat_drops_remaining.count(from)) {
-         if (debug_heartbeat_drops_remaining[from] == 0) {
-           debug_heartbeat_drops_remaining.erase(from);
+       auto heartbeat_drop = debug_heartbeat_drops_remaining.find(from);
+       if (heartbeat_drop != debug_heartbeat_drops_remaining.end()) {
+         if (heartbeat_drop->second == 0) {
+           debug_heartbeat_drops_remaining.erase(heartbeat_drop);
          } else {
-           debug_heartbeat_drops_remaining[from]--;
+           --heartbeat_drop->second;
            dout(5) << "Dropping heartbeat from " << from
-                   << ", " << debug_heartbeat_drops_remaining[from]
+                   << ", " << heartbeat_drop->second
                    << " remaining to drop" << dendl;
            break;
          }
        } else if (cct->_conf->osd_debug_drop_ping_probability >
                   ((((double)(rand()%100))/100.0))) {
-         debug_heartbeat_drops_remaining[from] =
-           cct->_conf->osd_debug_drop_ping_duration;
+         heartbeat_drop =
+           debug_heartbeat_drops_remaining.insert(std::make_pair(from,
+                            cct->_conf->osd_debug_drop_ping_duration)).first;
          dout(5) << "Dropping heartbeat from " << from
-                 << ", " << debug_heartbeat_drops_remaining[from]
+                 << ", " << heartbeat_drop->second
                  << " remaining to drop" << dendl;
          break;
        }