From 8484528c38a7913d0580396d78fd8ec8f3b7e411 Mon Sep 17 00:00:00 2001 From: shell-skrimp <116320856+shell-skrimp@users.noreply.github.com> Date: Wed, 19 Jul 2023 23:38:16 -0500 Subject: [PATCH] remove runtime.SetFinalizer --- cephfs/userperm.go | 7 +------ rados/conn.go | 3 --- rados/omap.go | 3 +-- rados/rados.go | 3 --- 4 files changed, 2 insertions(+), 14 deletions(-) diff --git a/cephfs/userperm.go b/cephfs/userperm.go index df214dea84..5adb8a5ff0 100644 --- a/cephfs/userperm.go +++ b/cephfs/userperm.go @@ -8,7 +8,6 @@ package cephfs import "C" import ( - "runtime" "unsafe" "github.com/ceph/go-ceph/internal/log" @@ -49,11 +48,7 @@ func NewUserPerm(uid, gid int, gidlist []int) *UserPerm { } p.userPerm = C.ceph_userperm_new( p.uid, p.gid, C.int(len(p.gidList)), cgids) - // if the go object is unreachable, we would like to free the c-memory - // since this has no other resources than memory associated with it. - // This is only valid for UserPerm objects created by new, and thus have - // the managed var set. - runtime.SetFinalizer(p, destroyUserPerm) + return p } diff --git a/rados/conn.go b/rados/conn.go index b866a796b6..c43b43e6d7 100644 --- a/rados/conn.go +++ b/rados/conn.go @@ -71,9 +71,6 @@ func (c *Conn) Connect() error { // Shutdown disconnects from the cluster. func (c *Conn) Shutdown() { - if err := c.ensureConnected(); err != nil { - return - } freeConn(c) } diff --git a/rados/omap.go b/rados/omap.go index 525826ba1a..3af0ec7b2f 100644 --- a/rados/omap.go +++ b/rados/omap.go @@ -8,7 +8,6 @@ package rados import "C" import ( - "runtime" "unsafe" ) @@ -44,7 +43,7 @@ func newGetOmapStep() *GetOmapStep { more: (*C.uchar)(C.malloc(C.sizeof_uchar)), rval: (*C.int)(C.malloc(C.sizeof_int)), } - runtime.SetFinalizer(gos, opStepFinalizer) + return gos } diff --git a/rados/rados.go b/rados/rados.go index 98d77ca8a3..0fe46bee43 100644 --- a/rados/rados.go +++ b/rados/rados.go @@ -7,7 +7,6 @@ package rados import "C" import ( - "runtime" "unsafe" "github.com/ceph/go-ceph/internal/log" @@ -74,7 +73,6 @@ func newConn(user *C.char) (*Conn, error) { return nil, getError(ret) } - runtime.SetFinalizer(conn, freeConn) return conn, nil } @@ -107,7 +105,6 @@ func NewConnWithClusterAndUser(clusterName string, userName string) (*Conn, erro return nil, getError(ret) } - runtime.SetFinalizer(conn, freeConn) return conn, nil }