]> git.apps.os.sepia.ceph.com Git - ceph-ci.git/commitdiff
common/buffer: fix compiler bug when enable DEBUG_BUFFER.
authorJianpeng Ma <jianpeng.ma@intel.com>
Thu, 10 Jan 2019 02:44:11 +0000 (10:44 +0800)
committerJianpeng Ma <jianpeng.ma@intel.com>
Thu, 10 Jan 2019 02:44:11 +0000 (10:44 +0800)
When enable DEBUG_BUFFER, met the following bug:

>>/home/ceph/jp-ceph/src/common/buffer.cc: In constructor ‘ceph::buffer::raw_malloc::raw_malloc(unsigned int)’:
>>/home/ceph/jp-ceph/src/common/buffer.cc:49:34: error: deduced class type ‘lock_guard’ in function return type
>> # define bdout { std::lock_guard lg(ceph::spinlock()); std::cout
                                  ^
>>/home/ceph/jp-ceph/src/common/buffer.cc:49:34: note: in definition of macro ‘bdout’
>> # define bdout { std::lock_guard lg(ceph::spinlock()); std::cout

At the same time, add a global lock to make different threads work well.

Signed-off-by: Jianpeng Ma <jianpeng.ma@intel.com>
src/common/buffer.cc

index 78bbc912f65cfa3dd4c6e8fd2fe7821c66da6187..41c267015b7524bd01a622ab4d52654a3a4a4cb9 100644 (file)
@@ -45,7 +45,8 @@ using namespace ceph;
 #define CEPH_BUFFER_APPEND_SIZE (CEPH_BUFFER_ALLOC_UNIT - sizeof(raw_combined))
 
 #ifdef BUFFER_DEBUG
-# define bdout { std::lock_guard lg(ceph::spinlock()); std::cout
+static ceph::spinlock debug_lock;
+# define bdout { std::lock_guard<ceph::spinlock> lg(debug_lock); std::cout
 # define bendl std::endl; }
 #else
 # define bdout if (0) { std::cout