1 // -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*-
2 // vim: ts=8 sw=2 smarttab
3 //
4 #include "include/ceph_assert.h"
5
6 #include "common/RefCountedObj.h"
7 #include "common/ceph_context.h"
8 #include "common/dout.h"
9 #include "common/valgrind.h"
10
11 RefCountedObject::~RefCountedObject()
12 {
13 ceph_assert(nref == 0);
14 }
15
16 void RefCountedObject::put() const {
17 CephContext *local_cct = cct;
18 auto v = --nref;
19 if (local_cct) {
(1) Event fun_call_w_exception: |
Called function throws an exception of type "std::length_error". [details] |
20 lsubdout(local_cct, refs, 1) << "RefCountedObject::put " << this << " "
21 << (v + 1) << " -> " << v
22 << dendl;
23 }
24 if (v == 0) {
25 ANNOTATE_HAPPENS_AFTER(&nref);
26 ANNOTATE_HAPPENS_BEFORE_FORGET_ALL(&nref);
27 delete this;
28 } else {
29 ANNOTATE_HAPPENS_BEFORE(&nref);
30 }
31 }
32
33 void RefCountedObject::_get() const {
34 auto v = ++nref;
35 ceph_assert(v > 1); /* it should never happen that _get() sees nref == 0 */
36 if (cct) {
37 lsubdout(cct, refs, 1) << "RefCountedObject::get " << this << " "
38 << (v - 1) << " -> " << v << dendl;
39 }
40 }
41