Commit Graph

5 Commits

Author SHA1 Message Date
Manish 6f90ce139c Code Lint: Fix lint errors caused by revive check for unused parameters
revive v1.3.7 added https://github.com/mgechev/revive/pull/966 which
checks for unused parameters in function literals. This caused several
lint errors in go-ceph code.

Signed-off-by: Manish <myathnal@redhat.com>
2024-02-13 07:22:13 +00:00
Sven Anderson 780f7014a2 internal: use runtime.Pinner in PtrGuard
Since Go 1.21 there is a runtime.Pinner API that allows to safely
pass structures with embedded Go pointers to C code.  In earlier Go
version we know that the garbage collector is non-moving, so it is
safe to pass Go pointers to C as well. This change adds two
implementations of PtrGuard, one for pre 1.21 that is basically a
no-op, and one for 1.21+ that uses runtime.Pinner.

Signed-off-by: Sven Anderson <sven@redhat.com>
2023-10-23 14:21:27 +00:00
Sven Anderson 46300ecae8 cutil: fix race condition in ptrguard tests
The finalizer of an object is called in a separate go routine, so we
might have to check several times for its completion.

Fixes: #545

Signed-off-by: Sven Anderson <sven@redhat.com>
2021-08-12 10:02:40 -04:00
Sven Anderson 1c72979ce0 ptrguard: assert that //go:uintptrescapes actually works
This adds a test that assures that the special //go:uintptrescapes comment
before the storeUntilRelease() function works as intended, that is the
garbage collector doesn't touch the object referenced by the uintptr until
the function returns after Release() is called.  The test will fail if the
//go:uintptrescapes comment is disabled (removed) or stops working in future
versions of go.

Signed-off-by: Sven Anderson <sven@redhat.com>
2021-03-19 09:47:19 -04:00
Sven Anderson 2bfdee2508 cutil: add test for PtrGuard
Signed-off-by: Sven Anderson <sven@redhat.com>
2021-02-08 14:50:56 +00:00