diff options
author | Rahat Mahmood <rahat@google.com> | 2018-05-17 15:05:15 -0700 |
---|---|---|
committer | Shentubot <shentubot@google.com> | 2018-05-17 15:06:19 -0700 |
commit | 8878a66a565733493e702199b284cd7855f80bf0 (patch) | |
tree | eb17447b112fabb267a031ca6ec60aa0e7fd7890 /pkg/refs/refcounter.go | |
parent | a8d7cee3e819f0e278c8da9ff2e7d72fbe0e82b8 (diff) |
Implement sysv shm.
PiperOrigin-RevId: 197058289
Change-Id: I3946c25028b7e032be4894d61acb48ac0c24d574
Diffstat (limited to 'pkg/refs/refcounter.go')
-rw-r--r-- | pkg/refs/refcounter.go | 8 |
1 files changed, 5 insertions, 3 deletions
diff --git a/pkg/refs/refcounter.go b/pkg/refs/refcounter.go index 1036553c7..3162001e1 100644 --- a/pkg/refs/refcounter.go +++ b/pkg/refs/refcounter.go @@ -194,9 +194,11 @@ type AtomicRefCount struct { weakRefs ilist.List `state:"nosave"` } -// TestReadRefs returns the current reference count of r. Use only for tests. -func (r *AtomicRefCount) TestReadRefs() int64 { - return atomic.LoadInt64(&r.refCount) +// ReadRefs returns the current number of references. The returned count is +// inherently racy and is unsafe to use without external synchronization. +func (r *AtomicRefCount) ReadRefs() int64 { + // Account for the internal -1 offset on refcounts. + return atomic.LoadInt64(&r.refCount) + 1 } // IncRef increments this object's reference count. While the count is kept |