Skip to content

Commit

Permalink
fix(vaultfs): Fix 32-bit panic
Browse files Browse the repository at this point in the history
Signed-off-by: Dave Henderson <[email protected]>
  • Loading branch information
hairyhenderson committed Jun 23, 2024
1 parent 9740435 commit 0c81c0c
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions vaultfs/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,13 @@ func newRefCountedClient(c *api.Client) *refCountedClient {
// other files are still open.
type refCountedClient struct {
*api.Client
refs uint64
refs atomic.Uint64
}

// var _ VaultClient = (*refCountedClient)(nil)

func (c *refCountedClient) AddRef() {
atomic.AddUint64(&c.refs, 1)
c.refs.Add(1)
}

func (c *refCountedClient) RemoveRef() {
Expand All @@ -36,9 +36,9 @@ func (c *refCountedClient) RemoveRef() {
}

// decrements the ref count by overflowing (see atomic.AddUint64 doc)
atomic.AddUint64(&c.refs, ^uint64(0))
c.refs.Add(^uint64(0))
}

func (c *refCountedClient) Refs() uint64 {
return atomic.LoadUint64(&c.refs)
return c.refs.Load()
}

0 comments on commit 0c81c0c

Please sign in to comment.