From 3c2e6ae97d6129cb8f5befb3e7bf4be16373f6a5 Mon Sep 17 00:00:00 2001 From: John Spray Date: Thu, 7 May 2015 18:17:37 +0100 Subject: [PATCH] client: use SaferCond in check_pool_perm Just because it's easier to read. Signed-off-by: John Spray (cherry picked from commit 289ee3b80ccce6bab2966f513a37332280d04a06) Reviewed-by: Greg Farnum --- src/client/Client.cc | 18 ++++++------------ 1 file changed, 6 insertions(+), 12 deletions(-) diff --git a/src/client/Client.cc b/src/client/Client.cc index c6a44778c13b2..e9e156a22c6da 100644 --- a/src/client/Client.cc +++ b/src/client/Client.cc @@ -10647,31 +10647,25 @@ int Client::check_pool_perm(Inode *in, int need) snprintf(oid_buf, sizeof(oid_buf), "%llx.00000000", (unsigned long long)in->ino); object_t oid = oid_buf; - Mutex lock("Client::check_pool_perm::lock"); - Cond cond; - bool done[2] = {false, false}; - int rd_ret; - int wr_ret; - + C_SaferCond rd_cond; ObjectOperation rd_op; rd_op.stat(NULL, (utime_t*)NULL, NULL); objecter->mutate(oid, OSDMap::file_to_object_locator(in->layout), rd_op, in->snaprealm->get_snap_context(), ceph_clock_now(cct), 0, - new C_SafeCond(&lock, &cond, &done[0], &rd_ret), NULL); + &rd_cond, NULL); + C_SaferCond wr_cond; ObjectOperation wr_op; wr_op.create(true); objecter->mutate(oid, OSDMap::file_to_object_locator(in->layout), wr_op, in->snaprealm->get_snap_context(), ceph_clock_now(cct), 0, - new C_SafeCond(&lock, &cond, &done[1], &wr_ret), NULL); + &wr_cond, NULL); client_lock.Unlock(); - lock.Lock(); - while (!done[0] || !done[1]) - cond.Wait(lock); - lock.Unlock(); + int rd_ret = rd_cond.wait(); + int wr_ret = wr_cond.wait(); client_lock.Lock(); if (rd_ret == 0 || rd_ret == -ENOENT) -- 2.39.5