]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
OSD: update_osd_stat take heartbeat_lock
authorSamuel Just <samuel.just@dreamhost.com>
Fri, 28 Jan 2011 22:07:47 +0000 (14:07 -0800)
committerSamuel Just <samuel.just@dreamhost.com>
Sat, 29 Jan 2011 02:24:12 +0000 (18:24 -0800)
Previously update_osd_stat had a race with code modifying heartbeat_from
causing the iterator increment to occasionally segfault.

Signed-off-by: Samuel Just <samuel.just@dreamhost.com>
src/osd/OSD.cc

index 925ac42c1432d16c8d7f246577aefadeec6e0c65..bf2da5a2193403497b2c23c2c17fabb8bf884e21 100644 (file)
@@ -1115,6 +1115,7 @@ void OSD::update_osd_stat()
 
 void OSD::_refresh_my_stat(utime_t now)
 {
+  assert(heartbeat_lock.is_locked());
   assert(peer_stat_lock.is_locked());
 
   // refresh?
@@ -1175,6 +1176,7 @@ void OSD::_refresh_my_stat(utime_t now)
 
 osd_peer_stat_t OSD::get_my_stat_for(utime_t now, int peer)
 {
+  Mutex::Locker hlock(heartbeat_lock);
   Mutex::Locker lock(peer_stat_lock);
   _refresh_my_stat(now);
   my_stat_on_peer[peer] = my_stat;