From: xie xingguo Date: Tue, 7 Jun 2016 01:38:00 +0000 (+0800) Subject: auth/cephx: fix race conditon for some public methods of KeyServer X-Git-Tag: ses5-milestone5~239^2~7 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=003289d4b9106d78a81d313c2200c6f9df8e3a95;p=ceph.git auth/cephx: fix race conditon for some public methods of KeyServer These methods are called only by AuthMonitor and are accessed without protection of internal lock, which is not safe. Signed-off-by: xie xingguo --- diff --git a/src/auth/cephx/CephxKeyServer.h b/src/auth/cephx/CephxKeyServer.h index 76b1c1363057..b742f052f527 100644 --- a/src/auth/cephx/CephxKeyServer.h +++ b/src/auth/cephx/CephxKeyServer.h @@ -241,10 +241,12 @@ public: } void clear_secrets() { + Mutex::Locker l(lock); data.clear_secrets(); } void apply_data_incremental(KeyServerData::Incremental& inc) { + Mutex::Locker l(lock); data.apply_incremental(inc); } void set_ver(version_t ver) { @@ -267,6 +269,7 @@ public: return (b != data.secrets_end()); } int get_num_secrets() { + Mutex::Locker l(lock); return data.secrets.size(); } @@ -280,6 +283,7 @@ public: dst = data; } void export_keyring(KeyRing& keyring) { + Mutex::Locker l(lock); for (map::iterator p = data.secrets.begin(); p != data.secrets.end(); ++p) {