]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
c++11: fix std::lock naming conflicts
authorNoah Watkins <noahwatkins@gmail.com>
Sun, 29 Dec 2013 18:32:22 +0000 (10:32 -0800)
committerNoah Watkins <noahwatkins@gmail.com>
Sun, 29 Dec 2013 21:31:59 +0000 (13:31 -0800)
Unfortunately, 'using namespace std;' is in pretty widespread use in the Ceph
tree, so we need to rename to avoid the conflict.

Example error output:

test/streamtest.cc:37:19: error: reference to 'lock' is ambiguous
  Mutex::Locker l(lock);
                  ^
test/streamtest.cc:32:7: note: candidate found by name lookup is 'lock'
Mutex lock("streamtest.cc lock");
      ^
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../lib/c++/v1/mutex:346:1: note: candidate found by name lookup is 'std::__1::lock'
lock(_L0& __l0, _L1& __l1)

Signed-off-by: Noah Watkins <noahwatkins@gmail.com>
src/test/librados/tier.cc
src/test/streamtest.cc
src/test/test_filejournal.cc
src/test/testmsgr.cc

index 883234f0ee5295d8c5ce507bc8e086098c2d40b4..401b6ab11386ad86727fc0ecfd82c27d9a02c130 100644 (file)
@@ -1074,7 +1074,7 @@ TEST(LibRadosTier, FlushTryFlushRaces) {
 
 
 IoCtx *read_ioctx = 0;
-Mutex lock("FlushReadRaces::lock");
+Mutex test_lock("FlushReadRaces::lock");
 Cond cond;
 int max_reads = 100;
 int num_reads = 0; // in progress
@@ -1095,7 +1095,7 @@ void start_flush_read()
 void flush_read_race_cb(completion_t cb, void *arg)
 {
   //cout << " finished read" << std::endl;
-  lock.Lock();
+  test_lock.Lock();
   if (num_reads > max_reads) {
     num_reads--;
     cond.Signal();
@@ -1103,7 +1103,7 @@ void flush_read_race_cb(completion_t cb, void *arg)
     start_flush_read();
   }
   // fixme: i'm leaking cb...
-  lock.Unlock();
+  test_lock.Unlock();
 }
 
 TEST(LibRadosTier, TryFlushReadRace) {
@@ -1149,12 +1149,12 @@ TEST(LibRadosTier, TryFlushReadRace) {
 
   // start a continuous stream of reads
   read_ioctx = &base_ioctx;
-  lock.Lock();
+  test_lock.Lock();
   for (int i = 0; i < max_reads; ++i) {
     start_flush_read();
     num_reads++;
   }
-  lock.Unlock();
+  test_lock.Unlock();
 
   // try-flush
   ObjectWriteOperation op;
@@ -1170,11 +1170,11 @@ TEST(LibRadosTier, TryFlushReadRace) {
   completion->release();
 
   // stop reads
-  lock.Lock();
+  test_lock.Lock();
   max_reads = 0;
   while (num_reads > 0)
-    cond.Wait(lock);
-  lock.Unlock();
+    cond.Wait(test_lock);
+  test_lock.Unlock();
 
   // tear down tiers
   ASSERT_EQ(0, cluster.mon_command(
index 21693ac8713c98052a2d576f42efe3fa6739f5ac..d4ccadf18e120d4fae570aed1543300397e5f603 100644 (file)
@@ -29,15 +29,15 @@ struct io {
 };
 map<off_t,io> writes;
 Cond cond;
-Mutex lock("streamtest.cc lock");
+Mutex test_lock("streamtest.cc lock");
 
 unsigned concurrent = 1;
 void throttle()
 { 
-  Mutex::Locker l(lock);
+  Mutex::Locker l(test_lock);
   while (writes.size() >= concurrent) {
     //generic_dout(0) << "waiting" << dendl;
-    cond.Wait(lock);
+    cond.Wait(test_lock);
   }
 }
 
@@ -60,13 +60,13 @@ void pr(off_t off)
 
 void set_start(off_t off, utime_t t)
 {
-  Mutex::Locker l(lock);
+  Mutex::Locker l(test_lock);
   writes[off].start = t;
 }
 
 void set_ack(off_t off, utime_t t)
 {
-  Mutex::Locker l(lock);
+  Mutex::Locker l(test_lock);
   //generic_dout(0) << "ack " << off << dendl;
   writes[off].ack = t;
   if (writes[off].done())
@@ -75,7 +75,7 @@ void set_ack(off_t off, utime_t t)
 
 void set_commit(off_t off, utime_t t)
 {
-  Mutex::Locker l(lock);
+  Mutex::Locker l(test_lock);
   //generic_dout(0) << "commit " << off << dendl;
   writes[off].commit = t;
   if (writes[off].done())
index 7365e97dec0a923f60b4e46c6b6e6667132c6f2f..3691fa64f4bec2df087e5a426017cf896b6517d5 100644 (file)
@@ -22,15 +22,15 @@ bool aio = false;
 
 // ----
 Cond cond;
-Mutex lock("lock");
+Mutex wait_lock("lock");
 bool done;
 
 void wait()
 {
-  lock.Lock();
+  wait_lock.Lock();
   while (!done)
-    cond.Wait(lock);
-  lock.Unlock();
+    cond.Wait(wait_lock);
+  wait_lock.Unlock();
 }
 
 // ----
@@ -120,7 +120,7 @@ TEST(TestFileJournal, WriteSmall) {
 
   bufferlist bl;
   bl.append("small");
-  j.submit_entry(1, bl, 0, new C_SafeCond(&lock, &cond, &done));
+  j.submit_entry(1, bl, 0, new C_SafeCond(&wait_lock, &cond, &done));
   wait();
 
   j.close();
@@ -138,7 +138,7 @@ TEST(TestFileJournal, WriteBig) {
     memset(foo, 1, sizeof(foo));
     bl.append(foo, sizeof(foo));
   }
-  j.submit_entry(1, bl, 0, new C_SafeCond(&lock, &cond, &done));
+  j.submit_entry(1, bl, 0, new C_SafeCond(&wait_lock, &cond, &done));
   wait();
 
   j.close();
@@ -150,7 +150,7 @@ TEST(TestFileJournal, WriteMany) {
   ASSERT_EQ(0, j.create());
   j.make_writeable();
 
-  C_GatherBuilder gb(g_ceph_context, new C_SafeCond(&lock, &cond, &done));
+  C_GatherBuilder gb(g_ceph_context, new C_SafeCond(&wait_lock, &cond, &done));
   
   bufferlist bl;
   bl.append("small");
@@ -173,7 +173,7 @@ TEST(TestFileJournal, WriteManyVecs) {
   ASSERT_EQ(0, j.create());
   j.make_writeable();
 
-  C_GatherBuilder gb(g_ceph_context, new C_SafeCond(&lock, &cond, &done));
+  C_GatherBuilder gb(g_ceph_context, new C_SafeCond(&wait_lock, &cond, &done));
 
   bufferlist first;
   first.append("small");
@@ -210,7 +210,7 @@ TEST(TestFileJournal, ReplaySmall) {
   ASSERT_EQ(0, j.create());
   j.make_writeable();
   
-  C_GatherBuilder gb(g_ceph_context, new C_SafeCond(&lock, &cond, &done));
+  C_GatherBuilder gb(g_ceph_context, new C_SafeCond(&wait_lock, &cond, &done));
   
   bufferlist bl;
   bl.append("small");
@@ -255,7 +255,7 @@ TEST(TestFileJournal, ReplayCorrupt) {
   ASSERT_EQ(0, j.create());
   j.make_writeable();
   
-  C_GatherBuilder gb(g_ceph_context, new C_SafeCond(&lock, &cond, &done));
+  C_GatherBuilder gb(g_ceph_context, new C_SafeCond(&wait_lock, &cond, &done));
   
   const char *needle =    "i am a needle";
   const char *newneedle = "in a haystack";
@@ -403,7 +403,7 @@ TEST(TestFileJournal, ReplayDetectCorruptFooterMagic) {
   ASSERT_EQ(0, j.create());
   j.make_writeable();
 
-  C_GatherBuilder gb(g_ceph_context, new C_SafeCond(&lock, &cond, &done));
+  C_GatherBuilder gb(g_ceph_context, new C_SafeCond(&wait_lock, &cond, &done));
 
   const char *needle =    "i am a needle";
   for (unsigned i = 1; i <= 4; ++i) {
@@ -416,7 +416,7 @@ TEST(TestFileJournal, ReplayDetectCorruptFooterMagic) {
 
   bufferlist bl;
   bl.append("needle");
-  j.submit_entry(5, bl, 0, new C_SafeCond(&lock, &cond, &done));
+  j.submit_entry(5, bl, 0, new C_SafeCond(&wait_lock, &cond, &done));
   wait();
 
   j.close();
@@ -453,7 +453,7 @@ TEST(TestFileJournal, ReplayDetectCorruptPayload) {
   ASSERT_EQ(0, j.create());
   j.make_writeable();
 
-  C_GatherBuilder gb(g_ceph_context, new C_SafeCond(&lock, &cond, &done));
+  C_GatherBuilder gb(g_ceph_context, new C_SafeCond(&wait_lock, &cond, &done));
 
   const char *needle =    "i am a needle";
   for (unsigned i = 1; i <= 4; ++i) {
@@ -466,7 +466,7 @@ TEST(TestFileJournal, ReplayDetectCorruptPayload) {
 
   bufferlist bl;
   bl.append("needle");
-  j.submit_entry(5, bl, 0, new C_SafeCond(&lock, &cond, &done));
+  j.submit_entry(5, bl, 0, new C_SafeCond(&wait_lock, &cond, &done));
   wait();
 
   j.close();
@@ -503,7 +503,7 @@ TEST(TestFileJournal, ReplayDetectCorruptHeader) {
   ASSERT_EQ(0, j.create());
   j.make_writeable();
 
-  C_GatherBuilder gb(g_ceph_context, new C_SafeCond(&lock, &cond, &done));
+  C_GatherBuilder gb(g_ceph_context, new C_SafeCond(&wait_lock, &cond, &done));
 
   const char *needle =    "i am a needle";
   for (unsigned i = 1; i <= 4; ++i) {
@@ -516,7 +516,7 @@ TEST(TestFileJournal, ReplayDetectCorruptHeader) {
 
   bufferlist bl;
   bl.append("needle");
-  j.submit_entry(5, bl, 0, new C_SafeCond(&lock, &cond, &done));
+  j.submit_entry(5, bl, 0, new C_SafeCond(&wait_lock, &cond, &done));
   wait();
 
   j.close();
index 4de779b5d7f0c353b9cd8530b833312054b4bc52..bcde69f8745c527de64b927c5ca8c270dd9e6f5b 100644 (file)
@@ -39,7 +39,7 @@ using namespace std;
 
 Messenger *messenger = 0;
 
-Mutex lock("mylock");
+Mutex test_lock("mylock");
 Cond cond;
 
 uint64_t received = 0;
@@ -55,10 +55,10 @@ private:
 
     //cerr << "got ping from " << m->get_source() << std::endl;
     dout(0) << "got ping from " << m->get_source() << dendl;
-    lock.Lock();
+    test_lock.Lock();
     ++received;
     cond.Signal();
-    lock.Unlock();
+    test_lock.Unlock();
 
     m->put();
     return true;
@@ -112,13 +112,13 @@ int main(int argc, const char **argv, const char *envp[]) {
   if (whoami == 0)
     isend = 100;
 
-  lock.Lock();
+  test_lock.Lock();
   uint64_t sent = 0;
   while (1) {
     while (received + isend <= sent) {
       //cerr << "wait r " << received << " s " << sent << " is " << isend << std::endl;
       dout(0) << "wait r " << received << " s " << sent << " is " << isend << dendl;
-      cond.Wait(lock);
+      cond.Wait(test_lock);
     }
 
     int t = rand() % mc.get_num_mon();
@@ -135,7 +135,7 @@ int main(int argc, const char **argv, const char *envp[]) {
     messenger->send_message(new MPing, mc.get_mon_inst(t));
     cerr << isend << "\t" << ++sent << "\t" << received << "\r";
   }
-  lock.Unlock();
+  test_lock.Unlock();
 
   // wait for messenger to finish
   rank->wait();