From be2e0aee00265e82e9140f15f12514ec19bbc630 Mon Sep 17 00:00:00 2001 From: Jianpeng Ma Date: Thu, 10 Jan 2019 10:44:11 +0800 Subject: [PATCH] common/buffer: fix compiler bug when enable DEBUG_BUFFER. MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit 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 --- src/common/buffer.cc | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/common/buffer.cc b/src/common/buffer.cc index 78bbc912f65..41c267015b7 100644 --- a/src/common/buffer.cc +++ b/src/common/buffer.cc @@ -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 lg(debug_lock); std::cout # define bendl std::endl; } #else # define bdout if (0) { std::cout -- 2.39.5