mirror of
https://github.com/seaweedfs/seaweedfs.git
synced 2025-04-05 19:32:01 +08:00
refactor
This commit is contained in:
parent
cb33ee006e
commit
94bd8b39cf
@ -1,9 +1,10 @@
|
||||
package mount
|
||||
|
||||
import (
|
||||
"github.com/seaweedfs/seaweedfs/weed/util"
|
||||
"sync"
|
||||
|
||||
"github.com/seaweedfs/seaweedfs/weed/util"
|
||||
|
||||
"github.com/seaweedfs/seaweedfs/weed/pb/filer_pb"
|
||||
)
|
||||
|
||||
@ -67,22 +68,26 @@ func (i *FileHandleToInode) ReleaseByInode(inode uint64) {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func (i *FileHandleToInode) ReleaseByHandle(fh FileHandleId) {
|
||||
i.Lock()
|
||||
defer i.Unlock()
|
||||
inode, found := i.fh2inode[fh]
|
||||
if found {
|
||||
fhHandle, fhFound := i.inode2fh[inode]
|
||||
if !fhFound {
|
||||
delete(i.fh2inode, fh)
|
||||
} else {
|
||||
fhHandle.counter--
|
||||
if fhHandle.counter <= 0 {
|
||||
delete(i.inode2fh, inode)
|
||||
delete(i.fh2inode, fhHandle.fh)
|
||||
fhHandle.ReleaseHandle()
|
||||
}
|
||||
}
|
||||
|
||||
inode, found := i.fh2inode[fh]
|
||||
if !found {
|
||||
return // Handle already released or invalid
|
||||
}
|
||||
|
||||
fhHandle, fhFound := i.inode2fh[inode]
|
||||
if !fhFound {
|
||||
delete(i.fh2inode, fh)
|
||||
return
|
||||
}
|
||||
|
||||
fhHandle.counter--
|
||||
if fhHandle.counter <= 0 {
|
||||
delete(i.inode2fh, inode)
|
||||
delete(i.fh2inode, fhHandle.fh)
|
||||
fhHandle.ReleaseHandle()
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user